The fact that consciousness exists does not necessarily mean that it is a product of evolution. It might, just as easily, be an epiphenomenon. Organisms of increasing complexity show increased levels of consciousness. Sensation is common to most organisms, while higher organisms are capable of more sophisticated forms of consciousness , such as reflex action, self awareness, representation, and perception of the past and the future. The development of consciousness in humans is a complex process that involves the selective strengthening and weakening of particular neural pathways.
Humans use elaborate mechanisms in the processes of brain development.
Yet all that is happening, in essence, is the construction of a multitude of neural connections and the subsequent modification of those connections brought on by input from the external world.