The basic concept is that mobs need to eat, and would die without food.
Horses, mules, donkeys, cows, sheep, chickens, pigs, rabbits, and llamas eat grass and wheat, pigs also eat other crops, chickens and parrots can eat planted seeds, parrots and bats eat jungle leaves, fish and turtles eat seagrass, kelp, and coral, squid, turtles, and dolphins eat fish, guardians and elder guardians eat squid, wolves eat sheep, ocelots eat chicken, spiders and cave spiders eat silverfish and endermites, endermites feed by living in endermen, shulkers eat endermites, endermen eat chorus plants, blazes feed by being in fire, magma cubes and slimes eat anything by engulfment, magma cubes also feed through sitting in lava, and mooshrooms and silverfish feed on soil nutrients.
Carcasses last longer (1 ingame day/night), and can be eaten by predators, or sometimes, if left alone, it is eaten by cave spiders or silverfish.
Soil nutrients are a gradient going throughout soil and plant blocks. If a block has 0 soil nutrients, it will decay if it is a plant block (other than wood), become dirt if it is grass of mycelium, or die if it is coral. Carcasses dissappearing will increase soil nutrients, and soil nutrients diffuse through soil and plants slowly.