The brain is attempting to understand itself.
As for some questions, there's some ideas on how it came to be, but who knows:
sleep - Photosynthesis requires sunlight. No sun, no photosynthesis. Plant life/cell life based on photosynthesis goes dormant. So, it uses those reserves while dormant...