Where did the energy of fossil fuel came from?
Fossil energy comes from the sun. All fossil fuels are ancient remains of living plants and animals. Plants use solar energy to make compounds with high energy content from simpler compounds, like CO2 and H2. Animals get all of their energy from plants, ultimately, so if either plants or animals die, energy from the sun will be stored in the dead matter. After millions of years of being buried, sediment will pile on top of this dead matter and refine it into coal, natural gas, or oil, depending on various factors. Those energy sources are very high in energy from the sun.