Where do we get all our energy from? Food. Where does the energy in food ultimately come from? Plants. Where does the biological energy in plants ultimately come from? Nowhere, they make it themselves through photosynthesis, using multiple types of energy from different sources.
So is all (a lot of) the energy available to all living things on Earth down to photosynthesis? It sure is, my biologist friend, it sure is (you know, except the microorganisms that can extract chemical energy from other sources like hydrothermal vents, or the breakdown of matter in soil by fungi, etc.). Let’s take a humbling moment of meditation while adoring this photo of a plant:
One day that weird-looking thing in the middle will be a pineapple ^_^
But wait. Don’t plants also use their own photosynthesised goodies (glucose) to provide energy for their own business (growth, reproduction, etc.) via respiration, and waste stored energy in their tissues upon their death? Of course they do. So less must be available for whatever eats the plant. And whatever eats the plant will also lose energy through excretion for example, so whatever eats this herbivore will have even less energy available to themselves.
Therefore, at each trophic level in the energy transfer (feeding) hierarchy there is a net loss of energy. This results in a pyramid…