Market failure occurs when prices do not fully reflect social costs. Externalities are spillover effects of a transaction that affect a third party not involved in the transaction. The negative health effects of passive smoking are an example of a negative externality, with the NHS and the passive smoker being the third parties not involved in the transaction.
Market failure occurs because marginal social cost (MSC) is greater than marginal private cost (MPC); MPC-MSC is the cost to passive smokers and the NHS. This leads to, under market conditions, too low a price and too high a quantity being consumed, hence market failure occurs. When MSC > MPC, there is a deadweight loss of social welfare.
((draw diagram with MPB, MSC and MPC, output on the x axis, cost and benefits on the y axis, and the deadweight loss of social welfare))