The first law of thermodynamics expresses conservation of energy: energy changes form but is neither created nor destroyed. In ecosystems, radiant or chemical energy becomes organic chemical energy, work, and ultimately dispersed heat. Energy-budget equations must therefore balance inputs, storage changes, exports, and respiratory losses. The second law adds directionality by stating that transformations increase entropy and reduce the fraction capable of doing work; together, the laws explain why energy is conserved quantitatively yet flows one way through ecosystems. Food-web structure also reflects population persistence: upper levels need enough total production and sufficiently stable prey populations to avoid demographic extinction. Detrital and grazing channels continually exchange material, because waste and mortality feed decomposers while microbial and detritivore biomass supports predators. Quantitative interpretation requires explicit system boundaries and time scales; otherwise export, migration, storage, or seasonal turnover can appear to violate energy balance. Thermodynamic constraints set broad patterns, but species traits, defenses, body size, habitat structure, and disturbance determine the efficiencies observed in a particular ecosystem.
Ref:
Fundamentals of Ecology, Odum & Barrett, 5th Ed., Ch. 3