Most discussions of electricity generation, especially from coal, are based only on accounting costs incurred by the generating companies. These costs do not represent the total costs of producing electricity because they ignore what are known as 'externalities'.
I'm glad you mentioned this because there's some incredibly toxic and environmentally-damaging processes used to produce "green" alternatives that are not currently factored into the production of that power.
Firstly, solar panels use incredibly toxic and hazardous chemicals produced or used during their manufacture including hydrochloric acid, sulfuric acid, nitric acid, hydrogen fluoride, 1,1,1-trichloroethane, and acetone. The more powerful the solar cell the more hazardous the production is; thin-film PV cells contain even more toxic materials than those used in traditional silicon photovoltaic cells, including gallium arsenide, copper-indium-gallium-diselenide, and cadmium-telluride (discussed further here
). The amount of toxic chemicals in the typical solar panel installation is huge and it's an environmental nightmare in itself; pollutants such as cadmium and lead can be washed out of solar panels by rainwater and so you shouldn't ever drink rainwater from a roof that has solar panels on it (not sure why there's not a public health alert on that topic?).
Solar panels also can't be committed to landfill once they're life-expired because of their toxic nature; they have to be disposed of by some other method. The state of California recently banned sending life-expired solar panels to landfill so they've been piling up in storage until they figure out what to do with them - the main problem is the lead and cadmium. They can be recycled but it's incredibly energy intensive and expensive; hence we should probably be looking at an environmental disposal levy on solar panels in this country.
Lithium batteries are even worse; lithium mining is an environmental nightmare. In South America and China, lithium mining has been irreparably poisoning the environment simply because the process of extraction and processing involves very toxic and hazardous chemicals that leach back into the environment. According to a report by Friends of the Earth, lithium and cobalt extraction inevitably harms the soil and causes air contamination discussed further in this Wired
article. Is there any way that these externalities are priced into the batteries? No, not really, in fact China has been ignoring the pollution caused by its own lithium mining because it only affects the rural poor.
Coal-fired plants can scrub their emissions so that any forms of particulate pollution can be minimised - and in any case most coal-fired plants are located outside of major population centres, so the particulate pollution thing isn't a substantial issue like it was in 1950's London when people were burning coal in their homes.
Personally I'd rather have more carbon dioxide in the atmosphere as opposed to poisonous chemicals leaching into the environment on account of "green" energy.