Public goods are those that are non-rival and non-excludable in consumption. Being non-rival implies that even if someone consumes it does not prevent someone else from doing it as well. Being non-excludable implies that no one will be prevented from consuming the good due to impossibility or because of a high price.
We can find an example of a non-excludable but rival good in a crowded street: it can be used by anyone but its use can be sometimes limited. On the other hand we use a coded television broadcast as a non-rival but excludable good: someone consuming it does not prevent someone else from doing so.
Finally to define a public good we may use the classical example of fireworks or street lights, once they are set they become non-rival and non-excludable and hence public goods. Nevertheless it is important to bear in mind that there can be different degrees of public goods. We can distinguish between pure public goods which are perfectly non-rival and non-excludable and between impure public goods which are rival and/or excludable to some extent. While pure public goods perfectly follow the non-rival and non-excludable condition, impure public goods are rival and/or excludable to some extent.
Normally these goods have to be provided by the public sector as the private sector is not interested in them due to the lack of profits. National defence, justice and public transportation, are just some examples.
Paul Samuelson’s work, specially his article “The Pure Theory of Public Expenditure”, 1954, is considered as the starting point of the development of the theory of public goods, as he formulated the efficiency condition for these goods.
The gratuity problem arises since once a public good has been produced and due to its characteristics (non-rival and non-excludable), anyone can enjoy it independently of who financed its production. In essence this problem is reduced to asymmetric information as people can hide their true preferences and this way they can still enjoy the good even if they don’t pay for them or pay much less