When animals eat plants, they consume the energy that is stored in the plant's tissues. This energy is then used by the animal for its own growth, maintenance, and reproduction. When other animals eat those animals, they in turn consume the energy that is stored in the tissues of the first animal.
And so on up the food chain. Each time an animal eats another animal, the energy that is stored in the prey's tissues is transferred to the predator. This process is known as energy transfer.
There is some loss of energy at each level of the food chain. This is because some of the energy is used by the animals for growth, maintenance, and reproduction. Some energy is also lost as heat. However, even after accounting for these losses, there is still enough energy transferred up the food chain to support all of the organisms that live in the ecosystem.
The Sun's energy is also used by other organisms in the ecosystem, such as bacteria and fungi. These organisms play a vital role in the cycling of nutrients in the ecosystem.