Just like any other sort of system, an ecosystem requires energy to operate. Energy for an ecosystem comes from the sun in the form of photons. When a photon of energy from the sun hits a green plant or an algae, it triggers a complicated chemical reaction in the chlorophyll pigments: photosynthesis. This is the only way on earth that living organic matter can be created out of sunlight and except for some bacteria, all living things depend on this energy. Organisms which can create their own organic material from the sun (or some other source as some bacteria can do) are called autotrophs.
Photosynthetic Equation: H2O + CO2 –> O2 + CHO’s
Since plants/algaes are the only organisms that can make organic energy out of the sun’s light, they are considered the primary producers in an ecosystem.
Let’s say that our incoming photons create 100 kilograms of algae in a pond. Why algae since you can’t even see it unless there is a lot? Most animal life in a pond either eats algae directly or eats smaller organisms that eat algae. Thus algae is the producer and everyone else is a consumer. Consumers which get their energy by eating (in other words they do not make their own energy) are heterotrophs. Consumers can be plant eaters (herbivores), meat eaters (carnivores), scavengers which eat dead things or detritus (detritivores), or they can eat just about anything (omnivores—humans, for example, are typically omnivores).
So you have 100 kilograms of algae to pass on to the algae eaters. About 90% of that available energy will be used up by those algae eaters just by their having to live: growth, respiration, energy lost as heat, energy required for movement, etc. So your 100 kilograms of algae can produce 10 kilograms of algae eaters. In other words, only 10% of the energy produced gets passed on from on trophic level (or level in the food web) to the next. Thus the more trophic levels you have, the less energy is available at the top. This is depicted as the trophic pyramid.

(from: Caduto, 1985)