We are purposeful beings. We act in all kinds of ways that are directed towards keeping us alive, allowing us to reproduce, and, depending which animal we are, seeing our offspring through to a time that they can reproduce themselves. In humans, the reproductive purpose has extended to seeing grandchildren appear. You have not completed your job as a parent until your children have reproduced.
All life is purposeful in this way. Bacteria acts in a way that will see it reproduce. Bees, a conifer, tigers. All are purposeful beings.
I think that we probably have become self-aware as a by-product of evolution that involved our brains growing much bigger (others have said most of this), stimulated by the huge possibilities of dextrous hands freed from the function of locomotion. In other words, our self-awareness did not evolve because it is advantageous to us. It evolved because exploiting strong, flexible limbs dedicated to exploring the world had huge benefits in terms of new foods, tools or learned techniques (the last two being a positive feedback into the selection of bigger brains). These bigger brains have stumbled upon the idea that we are all individuals in the world, that we are born and die, etc. These realisations may also be a positive feedback, they may also be neutral or merely not detrimental enough for the benefits to be outweighed (we all know that we perform any task more effectively when the conscious mind is not trying to control it, so it has negative consequences, but also may have positive ones, as I say below).
We have realised that we exist as individuals. And when we, in that very odd dualistic way that self-awareness feels to be (maybe not so odd given how it arises), look at ourselves, what do we find? We find a highly purposeful being that does not appear to do anything without a reason. This is us. We are doing these things. There is a time delay between our actions and our representation of those actions to ourselves in our consciousness. After we've done it, we see what we did, and we also see why we did it. The time delay is short, however. The representation feels like it has come with the action – it has required clever experimentation to prove to us that this is not the case, and it is only very recently that we have realised that it is not the case. Given that we feel that the the action and the representation of the action occur simultaneously, we attribute the cause of the action not to the pre-conscious purposeful being that in fact is the cause, but to the conscious reflecting being that we generally consider to be 'us'.
We see both the action and the wider context of the action in the model of reality generated by our brains, which is the content of our consciousness. They are gathered together into a meaningful whole, so the action and evidence for the reason for the action are there together. The strong urge we have to make sense of what we perceive has a wealth of evidence. We are always looking for meaning. We make the final link ourselves in what we do not realise is a post-fact reconstruction – we did this because of that. No wonder those experiencing a psychotic episode, whose ability to generate their models of reality is breaking down, talk about 'losing themselves' and no longer being in control.
This is the phenomenon that we commonly call free will.
There is constant feedback going on in our brains. Understanding of motivation that may be gained via the post-fact consciousness is readily available to the whole purposeful self for future actions. Any knowledge acquired by our conscious minds looking at the model of reality that is consciousness is freely available for the pre-conscious mind to use in the future. This could potentially rapidly speed up the potential for learning, and could be a reason why consciousness would be selected evolutionarily – another positive feedback on brain growth that was already being selected for clever hands.