Allocative inefficiency occurs when resources are not allocated in the optimal way to maximize societal welfare. It arises when the market fails to produce the socially optimal quantity of a good or service, leading to a deadweight loss in economic surplus.