A hydra eating: the mouth is where all the tentacles
come together,near the center of the picture.
The hydra is eating the round bug in its stomach.
May 2016 - Beginning about 3.8 billion years ago, during the Archaean Era, one-celled creatures were the earliest living things. They just floated in the ocean and took in food in the form of tiny molecules through their cell walls. Most of the living creatures on Earth still get their food this way today.
By about two billion years ago, during the Proterozoic Era, eukaryote cells developed the ability to extend their cell wall and capture their food in a bubble called a vacuole. That way it was harder for the food to get away from them. To break up the big molecules they captured, eukaryote cells used slave cells called mitochondria that lived inside them.
The first animals with more than one cell, like jellyfish or hydras, formed into the shape of bags two cells thick, so ocean water with food in it could reach all the cells on their inside as well as on the outside. That was about 600 million years ago. Food flowed in through the mouth, and waste (poop) flowed back out again the same way. Inside these bags, small one-celled bacteria lived that helped to digest the hydra's food in exchange for the hydra helping to catch it. All animals since then also have these bacteria.
Tiny roundworms, about 548 million years ago, evolved a more efficient system, in the shape of a tube instead of a bag, so that the food always flowed in the same direction, and then the waste left their body through the anus at the other end, the way your poop does. These worms were only a few millimeters long. Three million years later, annelids (segmented worms) divided their digestive tube into three parts: a crop that stored food, a gizzard that used muscles to grind up food, and the intestine. The worms swallowed small stones which collected in the gizzard, and then the gizzard's muscle ground the food against the stones to smash it up. Then the food went to the intestine, where bacteria broke it down into molecules that entered the circulatory system to be carried to all the body's cells. This solved the problem of how to get food if the animal was more than two cells thick.
By the end of the Proterozoic, about 542 million years ago, the first bigger animals, like arthropods (spiders and millipedes), had evolved a much more complicated digestive system. After the food came in through the mouth, it entered a wider part of the digestive tube, the stomach, where bigger chunks of food could be broken down. From the stomach, the food entered the midgut (like your intestines), where the food broke down into small molecules. On both sides of the midgut there were caecae which probably took out anything poisonous from the food before it went into the blood.
Fish, which evolved about 420 million years ago in the Silurian period, had a big advantage over other animals because they had jaws and teeth. Some fish still had gizzards to break down their food. But with teeth, fish could eat bigger, tougher things and chew them up. Unlike earlier animals, fish also have livers and kidneys, which take the poisons out of their food. Because these specialized parts prepared the food for the cells, the cells were able to get more energy out of the food with less work. That left more energy profit for the cells, and the cells used that energy to swim faster, move around more, and grow bigger smarter brains than earlier animals.
By 375 million years ago, in the Devonian period, the first frogs developed. Frogs had tongues to help catch and digest their food. Frogs also added a pancreas, a gallbladder, and separate large and small intestines, and they separated their poop from their urine (pee). Again, the tongue and saliva helped to pre-digest food so that the cells could get more energy from each molecule of food, and so frogs had more energy to spare than fish. Frogs used that energy to jump and to move on land, where it is harder to get around.
Reptiles (including dinosaurs) and birds, and mammals like us, digest their food much the same way as frogs do. One difference is that all birds have gizzards rather than teeth. Birds' ancestors had teeth, but birds have lost their teeth and have evolved to have beaks instead (every once in a while, a bird mutates back and does have teeth, which is why we have the expression "scarce as hen's teeth"). Without teeth, the birds would get less energy out of their food, but they use gizzards to replace their teeth.
People have an additional energy advantage over most other animals, because by around 200,000 years ago we began to pre-digest our food even before we ate it by cooking it over a fire. Cooking food softens it and breaks it down, so that we can get more of the energy out of it more easily.