Why is the sun the original source of energy for fossil fuels?

they decay

Oil comes from dead plants. To make plants grow, there must be photosynthesis, which in the simplest form takes energy from the sun, water and carbon dioxide to create sugar and other organic molecules. So, the chemicals in plants can be considered to have locked in energy from the organic chemicals, which is released if they are burned as plants, or millions of years later as fossil fuels.