This is a summarization of an essay by my girlfriend.
According to the market model of society the efficient distribution of products and services is attained through the direct exchange between and response of self-interest driven individuals. Since individuals seek to maximize returns and minimize costs, exchanges occur only when mutually beneficial; therefore, the market inherently optimizes the societal good. For this to work, several conditions must be met: individuals must act independently and only try to maximize their own utility; there must be perfect information about, competition for, and free movement of goods; and all the costs and benefits must be known and contained to the exchange. There are situations where not all of these conditions are met, which prevents the market from working efficiently.
One such example is that of public goods, which breaks the condition of perfect competition. Public goods are things that no one can be excluded from, such as water quality or national defense. Since no one can be excluded from using it, there is no way for providers to get a return on its production, even if there is a demand for it so the demand will not be met. The government can correct this inefficiency by using taxes to provide the good.
Another example is when an exchange produces externalities, which are when costs or benefits affect other uninvolved parties. An example of a positive externality is vaccination, where even the unvaccinated are protected from disease by herd immunity. An example of a negative externality is pollution, where poor water and air quality affect everyone, not just the ones who make the pollution. Since the decision makers involved do not bear all the costs and benefits, they are not taken into account, and the market either produces too much of something (in the case of negative externalities) or too little (in the case of positive externalities). The government can create regulations which can impose a cost or benefit to internalize the externalities. For example, a tax can be imposed on polluters, or vaccinations can be subsidized.
Another case where there is not adequate competition is for natural monopolies, when goods are produced most efficiently by a single supplier. This gives an advantage to the first or largest supplier and with insufficient competition, the monopoly can charge more than the good is worth. The government can step in by running the monopoly as a public utility or by regulating the price, quality and quantity of the good.
An efficient market requires everyone have perfect knowledge of their potential options. There are many situations where the participants involved do not have accurate or equal amounts of information. There is usually some cost in obtaining information, and information can be deliberately withheld. The government can reduce the cost of information by funding research, and can reduce information asymmetries by making information public.
Even in a perfectly efficient economy, some people will be unable to compete for resources, such as the young, the old and the disabled. There is no economic incentive to provide care for those who can offer little or nothing in return. The government can provide welfare to establish a baseline minimum quality of life.