An externality is the cost or benefit of an economic transaction to any party that was not part of the economic transaction. Examples would be the negative cost on society of smoking through second hand smoke inhalation, or the positive externality of herd immunity from getting a vaccine. An externality is a market failure because it results in an inefficient allocation of resources. This happens because the marginal social benefit (or the marginal social cost) do not align with the marginal private benefit (or the marginal private cost). If we look at the diagram where we use the example of demand and supply of cigarettes in a free market: the private cost line is lower than the public cost line. Thus the equilibrium price is lower than the optimal level and subsequently, so is the amount demanded.