First, a gas-fired power plant converts about 40% of thermal energy to electricity, discarding 60% to further heat the planet. Then a few more percent are lost in transmission lines and voltage-lowering transformers. Only then that electricity is used to heat water or air in one's house.
If you just directly burn that same gas in the house to produce heat, it's nearly 3x as efficient.
I only mentioned the gas-fired power station to make it an apples-to-apples comparison. It would be hard to compare e.g. to solar panels, even though direct hearing by concentrated sunlight might be feasible.
The best coal plants can archive 47% efficiency, https://www.brighthubengineering.com/power-plants/72369-comp...
It's worth it for a larger volume though. Not so much for a small flat.