In economics, an externality is a side-effect, either positive or negative, of production or consumption. It occurs when the impact of the activity spills over onto third parties, not otherwise engaged in the activity.
Negative Externalities
One common illustration of a negative externality is that of environmental pollution. Suppose I am the owner of a factory that makes and sells widgets, and I end up polluting a nearby stream with the waste products of my widget-making process. The impact of this pollution is neither felt by me nor by my customers, however, it is a negative externality for the neighbors of my factory, who suffer the consequences of the widget-fouled stream.
Externalities are an example of an imbalance in the free market, because the cost of a negative externality is paid by someone outside of the economic activity and not reflected in the price of production. Government often mitigates the imbalance represented by a negative externality by taxing the producer. By placing taxes upon factories that don't meet certain emission standards, government can incent factories to invest in necessary upgrades to their physical capital so that they meet those emission standards.
Positive Externalities
Externalities can be positive as well. Public education is one example of a positive externality. The positive effects are felt nationwide - education provides for a better informed citizenry, decreases unemployment, and increases national competitiveness in the global marketplace.
Another example of a positive externality would be that upon a farmer living next door to a beekeeper. The beekeeper's bees will naturally help pollinate the farmer's crops, providing the farmer with an unintentional benefit. Though the benefit is positive, this is also viewed by economists as an imbalance in the market because the benefit is not accounted for by the parties involved in the economic transaction. Government can address this by subsidizing and thus rewarding the producer for the positive externality, as is sometimes the case with public education.
Sometimes an activity can produce both positive and negative externalities. For instance, if a nightclub opens up in an otherwise sleepy town, that could generate positive externalities such as greater revenues for the surrounding businesses. However, that same nightclub could also bring noise pollution and contribute to increased criminal activity, driving renters in the area away.
Whether an externality is positive or negative, it is the government's role in a market economy to enact policies to deal with them, whether by taxation in the case of a negative externality or by subsidy in the case of a positive externality.