While markets, guided by the invisible hand, usually produce efficient outcomes, there are instances in which markets do not allocate resources efficiently and thus fail to maximize the size of the economic pie. Economists use the term market failure to refer to situations in which the market, left to itself, fails to allocate resources efficiently. Two common sources of market failures are externalities and market power.
Market power is the ability of an individual economic agent, or small number of economic agents, to influence the market price of a good or service. In this case, because the cable provider is the only source of internet, the cable provider faces no competition from other potential suppliers, enabling the cable provider the ability, or market power, to restrict the output of internet and charge higher prices. In short, the market power of the cable provider prevents the invisible hand from guiding the market to the efficient outcome.
An externality is an impact, positive or negative, of one individual's activities on the well-being of a bystander. In this case, since the residents of the housing plan, as bystanders, are harmed by the activities of the sewage company, the smells of sewage causes a negative externality. The presence of externalities can cause markets to produce too much or too little of a good or service, leading to an inefficient allocation of resources.
In cases of externalities and market power, the government can intervene to promote efficiency in the market.