What we have right now are three options : fossil fuels, renewable sources like wind/solar/hydro, or nuclear.
Fossil fuels kill millions a year related to pollution, and does make whole areas unlivable. About 16% of all fracking oil in the US gets spilled in nature every year[1], on top of crap like Flint. Coal is responsible for 80% of energy-generated related air pollution, worldwide[2]. They are not a good solution.
Natural sources are simply extremely limited in terms of access. Few countries can realistically really rely on these as a main source of electricity.
The, there's nuclear. We have fission, which is, while relatively safe (5 major impactful accidents since the rise of nuclear power, 3 of those being the three Fukishima plants), pretty damaging _when_ shit happens. However, are the damages realistically worse than fossil fuels? I'm not exactly qualified to figure this out myself but just looking at the numbers really doesn't make fission look that bad. Finally, there's nuclear fusion, which is a lot safer, while we've been making decent progress in the recent years, doesn't look like it's gonna run our cities any time soon.
So no, we shouldn't be burning coal, obviously, but if nothing's perfect, the logical option is the next best thing.
[1] https://www.bbc.com/news/science-environment-39032748
[2] https://www.ucsusa.org/clean-energy/decrease-coal-use