When you heat a can of beans on a campfire, you are transforming the chemical energy contained in the firewood into thermal energy (heat). As you are in your tent drifting off to sleep and the bean-induced-fart-chorus begins, you may ask yourself where the energy in that firewood came from. As with most energy sources, the answer is that it came from the
sun! That firewood was once a tree that was merrily pursuing its life's purpose of fashioning itself a body out of carbon dioxide, water, and sunlight, in a process known as photosynthesis.
Photosynthesis requires an energy source (sunlight), therefore the products of photosynthesis (wood, etc) can be thought to contain that photosynthesized energy. When you burn firewood, you are essentially running photosynthesis in reverse, releasing the energy from the sun that the tree went through so much trouble to absorb.
So, fire is cool because it allows us to unleash energy from the sun in small amounts, whenever we please, regardless of when that energy first arrived on earth. In the case of firewood, that energy arrived anywhere from a few years to a
few thousand years ago, depending on how long the tree had lived.
This same concept applies to
anything else we burn, even fossil fuels, which is where things get crazy.