This interview with neuroscientist David Eagleman is full of ideas. One of the most intriguing is his speculation that dreaming is a defence mechanism used by the visual cortex to prevent the encroachment of other senses.
We always think about the area at the back of the brain, where you do all the seeing, as the visual cortex. But if you go blind —
in fact, if we even just blindfold you tightly and stick you in a scanner for a little while —  we’ll see that other areas like touch and hearing are starting to encroach on that area.
We have electricity for lighting now, but in evolutionary time, 99.99 percent of it, we didn’t have that. You really were in the dark. Your hearing and your touch were just fine in the dark, but your vision was disadvantaged. And given the speed of takeover, that means the visual cortex is going to get taken over just by dint of the planet’s rotation. Years ago, my student Don Vaughn and I worked out a model showing that dreaming appears to be a way of keeping the visual cortex defended every night.