In the case of public goods, there are two reasons why markets do not give an efficient allocation of resources: indivisibility and externality. Since it is not practically possible for people to be charged for the benefit from the lighthouse (for example), these benefits are "external." In addition, the costs of the public good is indivisible, a condition that could create problems in itself. But -- when government provides the public good, for free -- the externality just balances the indivisibility and free provision is efficient.
In general, unfortunately, it's a bit more complicated.
Nevertheless, this illustrates an important point. Government action is itself a source of externalities, since routinely government charges some people (taxpayers) and benefits others without much direct connection between the two. The best we can hope for is that one externality may balance another, as it does in the case of free provision of public goods.
Perhaps this balancing act should be no surprise, since we live in an imperfect world. But this balancing sets a pretty high standard for government, and some economists (and others) doubt that real governments are capable of meeting the standard.

Copyright