Many economic activities create what are called "externalities": costs that aren't accounted for in their products but are paid for by society at large. Pollution is a major source of externalities, as it can lower the value of property, force people to spend money on medical costs, and even lead to early deaths.
Air pollution is estimated to have caused more than 100,000 early deaths in 2016. Most of these have come due to what are called fine particulates, which are small particles that can be readily inhaled and cause issues like stroke, heart disease, and lung ailments. So a group of researchers at Carnegie Mellon University decided to do an economic analysis of the issue for the United States. The researchers compared the costs of premature deaths from particulate pollution to the value added by the economic activity that produced the pollution to find out which polluting industries might provide a net benefit to the economy.
Their analysis showed that the plunge in coal use has caused electrical generation to shift from a net money sink to an economic positive. And that has left farming as the only major activity that generates more costs than it's worth.