These public goods are difficult to provide because of the non-rivalrous and non-excludable nature of them.
(Non)Excludable: The provider and/or consumer of the good has (does not have in the case of non-excludable) the ability to prevent some people from the consumption
(Non)Rivalrous: The consumption of a good by one person subtracts (does not subtract in the case of non-rivalrous) from another person's ability to consume.
Because each person benefits from a public good regardless of whether they contribute to the cost (and you cannot prevent them from benefiting) there is always an incentive for letting someone else provide the good. Most people have participated in group projects. Each person, regardless of the effort they put forth, will receive the same grade. Or, think of fireworks. People love fireworks but they can benefit from watching them without actually paying for them. Likewise with the examples such as social welfare, knowledge, defense, and public health. People would like to see them provided but do not wish to contribute to the cost. This discussion of the free-riding problem can be characterized by the "Prisoner's Dilemma"
Dilbert does not understand the Prisoner's Dilemma. If two prisoner's are placed in separate rooms and they committed a crime they would like to tell the same version of the story; but, they do not know the story their "partner in crime" will tell. They get a harsher penalty if they lie and the other prisoner does not. Therefore, there is a big incentive for each of them (in the absence of knowing what the other will do) to tell the truth so they can avoid the harsh penalty. Likewise with public goods: Everyone would be better off if the public good is provided but nobody wants to be the sucker that puts forth all the money, time, and effort to provide the public good while others do not contribute anything.
Another notable characterstic of public goods is that often times no individual can unilaterally provide the public good. This need for others to cooperate can be explained by the Prisoner's Dilemma but also by another diagram: Lindahl Taxation.
The cost of providing the public good is represented by MC or marginal cost. Each of our three people has a demand curve but they do not have a willingness to pay greater than cost; therefore, they have no individual incentive to provide the public good. If we add up all of their demand curves though we come up with a Social Demand curve. Where that Social Demand intersects marginal cost gives us the optimal quantity of the public good. The idea then is to charge each person a tax equal to what they would be willing to pay at that quantity.
But, can you get people to truthfully reveal their demand curve. This is a point that has been discussed at length in economics. To see this consider the following quote by economic luminary Paul Samuelson,
But, and, this is the point sensed by Wicksell but perhaps not fully appreciated by Lindahl, not it is in the selfish interest of each person to give false signals, to pretend to have less interest in a given collective consumption activity than he really has, etc.The bottom line is this, society might want certain public goods but people may not truthfully tell their value of those goods because then they would have to pay that price. This means that we cannot charge prices. Thus, we have might have the need for a non-market provision of such goods and services.