Why do we sleep?
Image is from the great web comic series, XKCD. My guess is that:
1) the process of storing long-term memories generates hallucinations.
2) if you're hallucinating, it's safer to disconnect your brain from your body, so you don't walk over a cliff chasing that unicorn.