Demerit goods are "goods or services considered to be harmful to people that would be over-provided by the market and so over-consumed." Examples include cigarettes, alcohol and junk food. Market failure is "the failure of markets to produce at the point where community surplus (consumer surplus + producer surplus) is maximised." This point is where marginal social benefit (MSB) equals marginal social cost (MSC). The consumption of demerit goods leads to market failure mainly because it creates negative externalities of consumption: "negative effects that are suffered by a third party when a good or service is consumed." Consumers take into account only their own benefit and ignore the costs their consumption imposes on others, so they consume more than the socially optimal quantity.
When a person buys a demerit good, they compare their own marginal private benefit (MPB) with its price. For a smoker, MPB is the enjoyment or relief they get from each cigarette; for someone eating junk food, it is the satisfaction of the meal. However, consumption also harms third parties. Second-hand smoke damages the health of people nearby, including children and non-smokers. The illnesses caused by smoking, alcohol and poor diet must be treated, often through publicly funded healthcare, so taxpayers bear part of the cost. Alcohol consumption can also lead to accidents and crime that harm others. These are external costs of consumption. Because consumers ignore them, the benefit of each unit to society as a whole is the consumer's private benefit minus the cost imposed on others, so MSB < MPB. In addition, consumers may underestimate the harm the good does to themselves, for example by underestimating the risk of addiction or illness, which makes their demand higher still.
In Figure 1, the demand curve, D = MPB, shows consumers' private benefit, and MSB lies below it. The vertical distance between them is the external cost of each unit consumed. Since there are no externalities in production, supply shows both marginal private cost and marginal social cost, S = MPC = MSC. The free market reaches equilibrium where MPB = MPC, at Qm, because consumers keep buying as long as their private benefit is at least the price. The socially optimal output, however, is Qopt, where MSB = MSC. For every unit between Qopt and Qm, the consumer's private benefit is high enough for them to buy it, so MPB ≥ MPC, but once the external cost is included, the benefit to society is below the cost of producing it: MSC > MSB. Each of these units therefore reduces community surplus. Because consumers base their decisions on MPB rather than MSB, these units are still bought and produced. The good is over-consumed and over-provided, and too many resources are allocated to it, resources that society would value more highly in other uses. The loss of community surplus is the shaded welfare loss, the triangle between MSC and MSB from Qopt to Qm. Since the market produces at Qm, not where MSB = MSC, community surplus is not maximised, and the consumption of demerit goods leads to market failure.