Let's start by internalizing how important the brain is to us human-folk: a whopping 60% of the body's glucose goes to the brain. Gram for gram the brain eats ten times more calories than does the body as a whole (20-25% consumption for only 2% of body mass) For an organism that evolved not knowing when or where it's next meal was coming, that big eater had better be good for something. Aristotle, who my history teacher thought was just the smartest man in history, blithely asserted that the brain must be a cooling engine for the body. (I like to kid Aristotle for just pulling stuff out of his ass like that. Bertrand Russel had some good zingers on him too. But I digress) Anyway, consensus neuroscience opinion these days is a little bit different. It seems to be the brain has basically two jobs (which we'll see in a sec is really the same job): 1) control motor function 2) predict the future.
Controlling motor function is almost obvious as soon as you think about it: really it's the only way the organism can affect its environment. One prime exhibit often cited for the rule "brain = locomotion" is the sea squirt, which will actually eats its own brain once it settles down to a sedentary life on a coral reef. But like John Lennon might have said, life is what happens while biologists make other theories: note the humble jelly fish and even slime molds seem to purposefully navigate their surroundings quite well without any central nervous system thank you very much. Sorry, digressing again. Either way, it's clear that at least our brain controls motor function.
But think about what a gargantuan task that is. First of all, just counting the 650 skeletal muscles in the human body (ignoring cardiac and smooth muscle tissue) presents the brain with 2 to the 650th power, or roughly 5 followed by 195 zeros(!), different possible motion states to control.* How can the brain possibly choose the few right needles among that astronomical haystack? Essentially via task 2) - predicting the future. The idea here is that the brain is constantly running internal simulations of its future possible muscle moves. Those simulations are believed to come from self-models of movement the brain creates and modifies over its lifetime. Comparing what the self-models say - i.e. what is internally predicted to happen milliseconds in the future - with the sensory feedback from the actual current motion is the basis for an extremely sophisticated control system. It's such a great system, that nature apparently said "hell, yes, let's do that!" at least as early as the Cambrian, about 500 million years ago.
Of course, those predictions will only be helpful if they contain not only the organism's own movements, but also the surrounding environment. It doesn't do an animal much good to successfully predict and then execute a move two steps to the left if that move takes it into the jaws of a predator. So predicting the future in general - like guessing what that predator is up to as well - is another equivalent way to describe the brain's job.
But now the brain really has a job on its hands. Try multiplying 5 followed 195 zeros times some even more ridiculously large number that represents all possible future states of your surrounding environment. Needless to say, brains don't do that. What they do though, is create and store internal models of the outside world as well. These models are kind of like look-up tables, or heuristics, built out of neural circuitry of course. So instead of actually calculating de novo what will happen next, just like in the case of motion, the brain activates a model appropriate to the sensory data; i.e. a model that will hopefully just tell it what in the world will happen next. Like is that roaring lion about to jump at me or the impala? Does she really like me or just the rabbit carcass I stole from the baby leopards? You get the idea.
But here's the funny thing: just how does your brain know there's a 'lion out there' in the first place? I mean your brain's hopefully tucked safely away inside your skull. The only thing it has access to is blood, chemical soup and electrical signals. Obviously then, it has to make its own model of a lion, because models are all it's ever going to see. "A lion chasing you up the tree" really means to your brain a model of "a lion chasing you up the tree". So the funny implication of all this is: the brain's not really predicting THE FUTURE. It's just predicting its own future; i.e. predicting the behavior of the models it creates. The brain is a self-prediction, self-modeling machine.
Rather than John Locke's blank slate, though, we're born with at least the rough drafts of many of our models. A good and quick read on this principle is Steven Pinker's classic The Blank Slate. Newborns a few hours old seem able to recognize faces, for example, and at four months visually process those faces at almost an adult level. Toddlers less than a year old already have some sense of cause and effect of object motion, and so on.
However much we're born with these models or develop them later, they're continuously shaped and modified throughout life by the brain reward system. The cookie in this system is the neurotransmitter dopamine. During learning to, say, play guitar (i.e. learning a model of you playing guitar), you're on a pay-as-you-go system. A cluster of specialized neurons in the mid-brain called the Ventral Tegmental Area, or VTA, releases dopamine only when the right notes are struck in the right way. Most of that dopamine lands in a nearby section called the nucleus accumbens, which also goes by the more technical name 'pleasure center'. This strengthens the neural circuits in your current model to reinforce the emergent, guitar-hero model of you. Once you get really good, though, the VTA figures your credit history is good and starts paying you up front. That is, the VTA releases the dopamine just before you hit the note - i.e. on the cue that makes your model say "OK, now gimme an F-sharp". Assuming you hit that F-sharp on time, the whole thing reinforces the predictive aspect of your model. If you're predictions keep missing the mark, though, the VTA will eventually not only revoke your credit, but stop dopamine payments altogether. That's when life can really suck, as any victim of withdrawal will tell you.
The whole system is much more complicated, of course, with feedback loops and braking mechanisms through other brain regions like the frontal cortex (that more deliberative part of the brain that Vulcans especially like). But the point is here that your models - you - chase dopamine like investment banks chase money. The metaphor with banks is on purpose: they- and you - will even chase it to their own destruction. That's what Peter Milner and James Olds found in the 1950s when they accidentally discovered the brain reward system in mice. The accident part came when they misplaced electrodes into another mid-brain region called the medial forebrain bundle. Zapping this region with a small voltage does essentially the same job as the VTA to nucleus accumbens mentioned above. In other words, the mice felt reealll good when the juice was on. Olds and Milner then let the mice zap themselves by connecting the voltage to a small lever they could press. Needless to say, the lever became very popular with the mice. So popular that even food, water and sex were ignored when there was lever to be pressed.
Next: Part III of III - how our models make us do stuff
*With the horrible oversimplification that each muscle is independently controlled to be either contracting or non-contracting.