In economic, an externality is a side effect on any party not directly involved, which lies outside the original decision.
An externality can be either positive (e.g., when enough population gets vaccinated, also non-vaccinated individuals gets for free the benefit of not contracting a disease) or negative (e.g. car driving causes external costs as pollution or congestion on other people).
The existence of externalities is a problem: those who suffer from external costs do so involuntarily, while those who enjoy external benefits do so at no cost.
Especially the negative ones result in outcomes that are not socially optimal.
The general solution to solve the externality is to offer compensation for the cost they inflict. For example: additionally charge the drivers. This can be done either for the trips they drive (e.g. raising the fuel price or the road/bridge/city tolls) or raising the upfront fee (the yearly car tax or the driver’s licence tax). Sometimes governments do both.
But actually the first method is the better one: as known, there is the average price and then there is the marginal price which is the one for one extra unit or in the driving example, for one extra trip.
To correct an inefficiency we need to address accurately the prices at the margin and not the average prices.
If I pay 100 Euro/year to enter the London centre, I can do it whenever I want, without incurring in extra marginal costs. But if I have to pay every time I enter the city centre, then I will think about it twice.
Another challenge is that the externality must reflect the cost of it but no more. In the driving example, the externality charge should probably vary according to time and place. For example, in the rush hour the driver should pay more because he is causing more harm to others.
At the end, the goal is not to discourage everyone but to get them to take into account the inconvenience they cause to others and to change a behaviour long-term.
As you see, the ideal externality charge addresses all the real external costs and only them and this is not easy: it requires a lot of information and knowledge. A perfect scenario for big data and machine learning!
[Update] Bonus paper: Big data impact on society, the positive and negative externalities associated with big data.