Epistemic status: provisional and speculative.
What is sleep? Is it a period of unconsciousness, punctuated with dreams which only happen when we experience them? Or are we conscious the whole time, and we generally only remember some dreams, but experience many more than we think we do? Do we really know that consciousness accompanies brain activity that appears to be conscious experience? We might ask if the being that is conscious of an unremembered dream is the same consciousness as our waking self.
These questions are empirical, to some extent. Here's one articlefrom 2016 pointing to some of the unknowns in the field. I may update this post later (or not, depending on if I think of it). For now, I would say that I lean toward thinking sleep is a time that you or I do not experience, except for our dreams. I lean toward thinking that when we talk in our sleep, or sleepwalk, we are possessed by some other spirit. (I think possession is not too rare and shouldn't be seen as any more stigmatizing than mental illness -- a dark reality at times, but more medical than horror film.) When we have dreams that we don't remember, it may be that we ourselves never have them, and that when we have ones that we do, we may be experiencing the exact same experiences as the spirit that possesses us when we sleep, which has all our dreams.
Why do we sleep? We seem to need to or else we go insane. The materialist view would be that something in our brains needs sleep. The "spiritualist" view would be that there is some kind of spirit that sometimes breaks into our consciousness when we are mentally ill, and this spirit is affected by whether we sleep. It could be that God runs two different realities out of the same lives. Both our sleeping self (which may be identical with our "unconscious" self -- a consciousness that shares our experience body to some extent and has its own personhood and will) and our waking rational self. Each of us gets the chance to take the lead, the conscious self during the waking period, and the "unconscious" during sleep. Dreams are where we get a taste of the other self's reality, and perhaps it is able to see what we see with our eyes and experience with our other senses at times, or all the time. It may experience our lives as dreams, or as we do, which may be something as relatively incomprehensible to it as its normal experiential fare -- dreams -- are to us. If this unconscious self doesn't get the chance to be itself, it breaks into our consciousness, perhaps out of a desire to be heard, or simply with the violence of unhappiness.
Why would God arrange things like this? I'm not really sure. The dream world seems to some to be an independent reality. Certainly it can be seen as being made of consciousness and connected by God, subject to his opinion. But it is a different kind of consciousness. Maybe that consciousness is an integral part of God's consciousness, and he wants it to be expressed in some of his creatures.