Market failure is a situation where the free market fails to allocate resources efficiently, leading to a suboptimal outcome for society. It occurs when the market mechanism does not account for all the costs and benefits associated with the production and consumption of a good or service.