The exceptions occur when the costs incurred by the producers are not the only costs and/or the benefits enjoyed by the consumers are not the only benefits. In other words there are significant externalities, and especially negative ones. In such cases, the Marginal Social Cost (MSC) is not equal to Marginal Cost (MC) for the producer and the Marginal Social Benefit (MSB) is not equal to the Marginal Benefit (MB) for the consumer. Though equilibrium is reached when the MC equals MB, it is not an efficient equilibrium. He writes,
"The market reaches equilibrium when the cost of producing the last pound is exactly equal to its value. If the costs incurred directly by sellers are the only relevant costs of expanding potato production, and if the benefits to potato buyers are the only relevant benefits, the invisible hand gets things just right. The production and consumption of many other goods, however, generate costs or benefits that fall on people besides buyers and sellers. Producing an extra gallon of gasoline, for example, generates not just additional costs to producers, but also pollution costs that fall on others.
As before, market forces cause production to expand until the seller’s direct cost for the last unit sold is exactly the value of that unit to the buyer. But because each gallon of gasoline also generates external pollution costs, the total cost of that last gallon produced is higher than its value to consumers. The upshot is that gasoline consumption is inefficiently high. That simple example captures the classic breakdown in the invisible hand when a product’s market price doesn’t reflect all its relevant social costs and benefits. In such cases, the simplest solution is to discourage consumption by taxing it...
That the invisible hand often breaks down is actually good news. After all, we need to tax something to pay for public services. By taxing forms of consumption that generate negative side effects, we could not only generate enough revenue to eliminate budget deficits, but also help steer resources toward their most highly valued uses.
Because such taxes make the economy more efficient, it makes no sense to object that they impose hardships on low-income families. Again, an efficient policy is one that maximizes the size of the economic pie. And with a bigger pie, it’s always possible for everyone to get a bigger slice."