During our sleep we are plugged into our unconscious mind i.e. the Spirit. However, our conscious mind, which experiences the world by the sensory organs, is taken away at the time of sleep.
As the Holy Quran states:
"Allah takes the 'Soul(Nafs)' when death comes, and also at the time of sleep..." (39:42)
The Soul or Nafs is your 'self', it is responsible for making decisions. Therefore soul represents the 'conscious mind'. On the other hand we have 'Spirit' which is said to belong to Allah as is stated in the Holy Quran and represents the 'unconscious mind' (Note that unconscious mind also includes the various systems and processes going on within the body since the brain performs them unknowingly and unconsciously)
So it can be said that during sleep, we have our unconscious mind i.e. spirit with us, but our conscious mind(soul) is taken away by Allah.
There are different theories and concepts about where the conscious mind is at time of sleep IF it is not within the body. Some say that it remains in our body but is switched off, yet it could also be possible that our conscious mind roams somewhere in the heavens, and thus, experiences felt by it are transmitted to us - resulting in dreams. Or it could just be that once our unconscious mind is ON, it starts playing random bits and pieces from our memory on our inner visual screen.
DREAMS DURING REM:
Dreams are of different kinds, but the most mysterious dreams are those that we see in the state of deep sleep or REM sleep. Most scientific research is done on the initial state of sleep which is also known as hypnagogia. This is the state in which you're not deep in sleep but neither are you fully awake. You usually experience the effects of recent and present memories in this state, like falling off from a cliff or floating in water after spending a day at sea.
But the dreams of deep sleep and REM sleep cannot be described under this category because of their distinguished nature... Most prophetic dreams, and dreams that later turn into reality come in this state of sleep and thus are more mysterious in their nature.
In my opinion, our body has a connection with our conscious and unconscious state of mind, or in other words the body is connected with both the soul and the spirit during wakefulness... but during deep sleep your body loses the connection with your conscious mind(soul) and thus you only experience what your unconscious(spirit) feels.
So, in vague terms we can say that when our unconscious or spirit is really strong.. it can sense much more than what is usually understandable to our conscious mind ..which explains the bashara or prophetic dreams somewhat.
Its like the sixth sense, its not just that sixth sense exist in some beings, but its existence points toward the fact that somewhere in the world this information about future and these signals about upcoming harm are being transmitted. . . which we(with our limited consciousness) cannot feel, but if our spirit is really strong it can interpret those signals while dreaming.
Now here, I would like to point to the fact how Islam has emphasized on strengthening our spirit through Namaz.. specially namaz-e-shab(Night prayer) which is the best form of meditation besides being a great form of worship, and is guaranteed to strengthen your spirit and bless you with special knowledge and sight.
Praise be to Allah