A market economy will in theory achieve an efficient allocation of resources, but only with very extreme assumptions. In real world this will not happen due to what is called market failure. In microeconomics there are five types of market failure: public goods, monopoly, externalities, poor definition of property rights, and incomplete information and uncertainty. A lot of government policies try to improve efficiency in the economy by reducing the impact of microeconomic failure.

Public Goods

A 100% public good is a good or service from which nobody can be excluded and that can be consumed simultanously by everyone. In other words, it's non-rival and non-excludable. Examples of pure public goods are lighthouses and national defence.

A good may also be excludable and non-rival, meaning that it is possible to exclude someone from it, but the ones not excluded will not decrease the available units by consumptions. This may include cable television or a bridge.

The opposite, non-excludable and rival, means that there is a limited number of units of the good, but it is impossible to exclude someone from it, e.g. air or fish in the ocean.

The problem with public goods is that they create a free-rider problem. A free-rider is someone who consumes a good or service without paying for it. People have little incentive to pay voluntarily for public goods. If private companies cannot generate any revenue for these goods they will not supply them and the market allocations will be less than the efficient level. It is therefore common that the government will provide a public good and pay for it with tax revenue, in order to avoid the free-rider problem.

Monopoly

Monopoly and rent seeking prevent the resources from being allocated efficiently. A monopoly power will usually increase its profit by restricting output and increasing price.

Some monopolies arise legally from barriers to entry created by the government. These monopolies are created in order to take advantage of economies of scale, as well as to provide overall better goods or services for the public. Consider the railroad companies in Great Britain during the mid 19th century. All the companies were privately own and there were great competition. This resulted in railroads not compatible with each other and a lot of overlapping tracks. A legal monopoly might have been more efficient.

A major activity of government is however to regulate monopoly and to prevent cartels and other restrictions on competition. Even monopolies legally created by the government must be regulated to ensure that their monopoly status does not lead to inefficiency.

Externalities

An externality is a cost or a benefit that falls on people not participating in the transaction creating it. A very common externality is pollution. Since there is no market for pollution, a polluting factory will not sell the pollution, but instead just get rid of it. From the factories point of view, this is most efficient, since it will not have to deal with the cost. External costs are often regulated by the government.

The opposite of external cost is external benefit. This may include a home owner keeping a lovely garden, which will benefit the ones passing by. The home owner does however only consider the personal benefit when paying for the garden - may it be hours of work or money. Even though external benefits are inefficient, it is uncommon for governments to regulate them.

Poor definition of property rights

For economic transactions to work efficiently there has to be defined property rights. If there was no clear system of individual or company ownership, you could not rightfully buy or sell a resource or product in a market. This is why a legal system is needed to help market system to work properly.

Incomplete information and uncertainty

If not all information is available to all parties involved in a transaction, the result may not be efficient. Two common types of market failure based on this are moral hazard and adverse selection.

Moral hazard exists when one of the parties to an agreement has an incentive, after the agreement is made, to act in a manner that brings additional benefits to himself or herself at the expense of the other party. The reason that this exists is because it is too costly to monitor the actions of the other party. For example, someone hired with a fixed wage may not work as hard as someone hired with a wage reflecting the actual work done.

Adverse selection is the incentive for someone to hide information that can be used for their own advantage. Consider for example someone trying to sell a used car without telling the other party about possible damages.