Perhaps we tend to anthropomorphise the language we use to describe evolutionary processes and this gives the misleading notion of intention. Think of it this way, brains which protected vision would have a survival advantage over ones that didn't and so that is why dreaming became a feature in lineages where sight is a priority sense. As for plasticity in general, there are accounts of people losing significant amounts of cortical tissue to injury or disease, and yet who seem to manage live a 'normal' life. How on earth could that be possible ? Neural plasticity is the answer to that question, the brain is very quick to reconfigure cortex, to reuse it. The brain is not a fixed structure, it is dynamic, responsive, adaptable, or 'plastic', in the jargon.
How does it happen.....the process by which the 'brain' comes to know that there will be a survival advantage with a protected vision and then it goes about designing such a system..?! Just through random genetic variations and natural selection...?!
I have already linked an article in the 'Selfish Gene' thread that highlights the fact that genetic variations happen due to signals from the general physiology. Here is a part of it.
**********
The DNA molecule on its own does absolutely nothing since it reacts biochemically only to triggering signals. It cannot even initiate its own transcription or replication.
It would therefore be more correct to say that genes are not active causes; they are, rather, caused to give their information by and to the system that activates them. The only kind of causation that can be attributed to them is passive, much in the way a computer program reads and uses databases.
**********
The system is much more responsive and intelligent than you are giving it credit for. And this responsive intelligence is not a property of the brain but a part of the entire system. The brain is only a part of it.