The market demand for a good or service is determined by the sum of the demands for the good or service from each individual consumer. Essentially, you add up the individual consumers' demands to determine the market demand. For a rival good (a good where one person's consumption reduces the amount that is available for everyone else), it is as simple as adding up the quantity demanded at each price. So, if there are only two consumers, and at price P1 the first consumer demands Q1 units and the second consumer demands Q2 units, then market demand at the price P1 is (Q1+Q2).
However, when a good is non-rival, it is no longer quite that simple. Non-rival goods are those where one person consuming the good does not reduce the amount of the good or service available for everyone else. Disney+ is one example. If one person pays for a Disney+ subscription, that doesn't reduce the amount of Disney+ subscriptions that are left for other people. Another example of a non-rival good is a public good. Public goods are goods that are non-rival, and non-excludable (non-excludable means that if they are available for anyone, then they are available for everyone - we'll come back to this point later). Examples of public goods include street lights, or policing.
Now, if we want to know the market demand for street lights, we can't add up the quantity demanded at different prices. That's because two people can consume the same light - remember, it is a non-rival good. The market demand for a non-rival good is found by adding up the marginal private benefit that each consumer gets from the good, to give you the marginal social benefit.
To see how this works, consider the diagram below. There are three people (A, B, and C), and their marginal private benefits for street lights are shown by MPBA, MPBB, and MPBC respectively. The diagram is quite busy, so let's break it down and note what it shows. Person A benefits a lot from street lights. They receive a marginal benefit of P5 for the first little bit of street lighting, and continue to benefit from street lighting all the way out to a quantity of Q4 (this is their marginal private benefit curve, MPBA). Person B benefits less than Person A. The receive a marginal benefit of P3 for the first little bit of street lighting, and continue to benefit from street lighting up to a quantity of Q3 (this is their marginal private benefit curve, MPBB). Finally, Person C receives a marginal benefit of P4 for the first little bit of street lighting, and continue to benefit from street lighting only up to a quantity of Q2 (this is their marginal private benefit curve, MPBB).
What does that mean for the marginal social benefit - the benefit of street lighting to society? The first little bit of street lighting provides Person A with a marginal private benefit of P5, Person B with a marginal private benefit of P3, and Person C with a marginal private benefit of P4. So the marginal social benefit of the first little bit of street lighting is (P3+P4+P5), as shown in the bolder line on the diagram. Now, as the quantity of street lighting increases, the marginal private benefit for each person decreases, until we get to Q2. At that quantity, the marginal private benefit for Person C has fallen to zero. At that quantity, the marginal private benefit for Person A has fallen to P4, and the marginal private benefit for Person B has fallen to P1. So, marginal social benefit at the quantity of Q2 is equal to (P1+P3) - notice that is also equal to P4 (for no reason other than it made it a bit easier to draw the diagram!). Moving on, once we get to the quantity Q3, the marginal private benefit for Person B has also fallen to zero. At that quantity, the marginal social benefit is going to be made up only of the marginal private benefit to Person A, which is equal to P2. And at quantities up to Q4, the marginal social benefit curve is exactly the same as Person A's marginal private benefit curve, MPBA.
Now, we are in a position to consider what happens if we offer street lighting for sale. First, we need to know the price of street lighting. Let's assume that the cost of each unit of street lighting is constant, and equal to P4. That is represented by the marginal social cost curve (MSC) on the diagram below. If we set the price of street lighting equal to its cost (P4), then what would happen? At that price, notice that both Person B and Person C would choose not to pay for street lighting, because the price is above (or equal to) the highest marginal benefit that they receive for the first little bit of street lighting. They would simply opt out of paying for street lighting. Person A is willing to pay more than P4, but they will only be willing to pay for Q1 units of street lighting. The market will provide Q1 units of street lighting, entirely paid for by Person A.
That is a problem. The optimal quantity of street lighting is the quantity where marginal social benefit is equal to marginal social cost. That's the quantity Q3. This market isn't going to provide enough street lighting to maximise welfare for society. The problem here is that the good is non-excludable - you can't easily force Person B or Person C to pay for it. If the street lighting is available to anyone, then it is available to everyone. Person B and Person C will benefit from the street lighting paid for by Person A, and won't feel the need to pay for any additional lighting themselves. Person B and Person C are free-riders. This is the reason why public goods are usually provided by the government. [*] The private market would not provide enough. Consider what would happen if the cost of street lighting was higher than P5. Even though marginal social benefit is higher than that, if the cost (and price) of street lighting was higher than P5, nobody would be willing to pay for it!
Finally, let's consider the economic welfare implications of the public good in this example. If the market provides only Q1 units of street lighting, the consumer surplus (the difference between what society is willing to pay for the good, and what is actually paid for the good) is equal to the area ABDC. You may wonder why the consumer surplus isn't equal to the area FDC, which is the surplus that Person A (who is the only one paying for street lighting receives). [**] Remember the free riders Person B and Person C though - they receive benefit (and consumer surplus) from the street lighting, even though they aren't paying anything towards it. So, the consumer surplus is ABDC, not FDC. Moving on, there is no producer surplus (because price is equal to cost for every unit of street lighting). So, total welfare is equal to the area ABDC.
If instead the government provides street lighting, and provides the optimal quantity Q2, then consumer surplus increases to the area AEC. Again, because there is no producer surplus, the area AEC also represents the area of total welfare. There are welfare gains from the government providing street lighting. Or, another way of thinking about it is that if the market was providing street lighting, total welfare would be lower by the area BED - that is the deadweight loss of private provision of this public good.
*****
[*] Of course, the government doesn't necessarily need to provide the public good itself. It can contract and pay a private firm to provide the lighting, up to a quantity specified by the government.
[**] This important question was raised in my ECONS102 class yesterday, so I thank them for the inspiration to address the point.