Electricity is generated by different sources like coal, natural gas, solar, and wind. The relative cost of electricity from each of these sources is different because of a few different factors.
Coal is typically the most expensive electricity source since it requires mining and lots of energy to process and burn it. Natural gas is cheaper than coal, but it still costs money to get it out of the ground and transport it.
Solar and wind energy are often the cheapest electricity sources because they don't require mining and they don't need to be burned like coal or natural gas. Sun and wind is free, so it makes electricity from solar and wind cheaper to generate.