Understanding how our brain works
Brains are pretty good. With a brain, you can sense and experience the world around you, think, feel, learn and remember new things. But ultimately what brains and nervous systems seem to be there for, is to help coordinate the interactions between cells, so they can move and behave in unison.
Humans brains can consider lights, sounds, little chemicals floating in the air, the taste of food and how things feel from our sensory cells, then tell our muscle cells to behave in a synchronized fashion to do something beneficial based on it all.
Our nervous system sends and receives signals in 2 main ways, through neuron signals and hormone signals. Neurons are cells that send and relay action potentials as signals. Signal comes in one end, goes to other end and can connect to another neuron that does the same. In this way they form a network all over your body that centralizes around your brain.
This type of signal is how your senses send signals to the brain and how motor functions are signalled from the brain. There are lots of different neurons that do different tasks and the brain itself operates with neurons.
There are other kinds of cells in there too. Some feed and regulate neurons, and others fight off bacteria and viruses and do cleanup. But your neurons and how and why they connect is really where the fun happens.
Hormones are chemicals that signal responses in the body. So some cells can excrete a hormone, and then other cells have receptor proteins that a hormone can bind to and initiate some response, like the production of a protein. While neuron signals are much more precise, hormones can enter the blood stream and effect everywhere, depending on what cells have the receptor. They generally have slower effects than nerve signals and can signal things like mood and growth. So with hormones and neuron signals, cells can grow and divide together, they can sense and move together, and otherwise just behave in coordinated ways.
You can start classifying behaviours. Are they learned, like learning to use utensils or learning to read. Are they more intrinsic, like sea turtles instinctively knowing to head toward the light of the sea at birth. Are they uncontrollable and involuntary like your heart beat? Are they voluntary like waving your arms around. Or a mix, like breathing. Or maybe they're a reflex arc, that doesn't travel through the brain at all. But how and why did these behaviours come to be? Why did brains evolve?
Well, brains evolved for the same reason everything else did. The genes that make neurons, hormones, hormone receptors and everything else that influences behaviour, didn't come to be for any reason but for the reproduction of those genes. While this isn't the only thing that defines that behaviours are like. Because these elements that facilitate behaviour are coded for by DNA that needs to reproduce to continue, some of the behaviours they facilitate can seem pretty harshly self-interested. Like black headed gulls who nest out close to one another, will eat the babies of their neighbors that aren't paying attention. Sounds brutal, but to them and their genes, it's just another food source. And it's probably a lot easier than going fishing. There's no such a thing as "for the good of the species" when we talk about why genes and traits get passed down. It's all only for the reproduction of the genes.