Flatworms were the first animals to evolve anything like a brain, but it’s really just a thickened part of the main nerve at one end of the flatworm. That was about 550 million years ago, in the Proterozoic period.
When animals moved out of the water to live on land, they needed to evolve fancier brains that could help them to survive in this new environment. Reptiles have three parts to their brains. The front part is for smell, the middle part is for seeing things, and the back part is for balance and for coordinating the muscles on the left and right sides of the body (just like in flatworms). Another small part of the brain, between the smell part and the seeing part, was used to put together all the data and figure out what to do.
Mammal brains were the next big change from reptile brains. The reptile brain stayed there, but mammal brains grew another layer over the top of the reptile brain, much bigger. Mammals put a lot more energy into their brains.
Another big jump in brain size may have come when early humans learned how to cook food. Cooking food makes it easier to get a lot more energy out of it, so humans had enough energy to build bigger brains. Today, your brain uses about a fifth of the energy from the food you eat.