The original source of energy in fossil fuels is the sun. Over millions of years, ancient plants and microorganisms absorbed sunlight through the process of photosynthesis. As these organisms died and were buried under layers of earth, they transformed into fossil fuels such as coal, oil, and natural gas due to heat and pressure from the overlying materials.
In essence, fossil fuels are made from the stored sunlight energy that was captured by living organisms in the distant past. This process not only stores solar energy but also takes place over geological time scales, making fossil fuels a significant, albeit finite, source of energy for modern society.