There are four different dream theories in biological psychology. The oldest Freudian theory reveals that the dream serves the purpose to keep us asleep. When the reality is harsher than nightmares as it was in KZ, a person did not benefit from waking up.
Dreaming is one of the types of inspirations that a person experiences. Psychologically, dreams are reflecting the state of a persons being and often when some dreams come as good then we feel good and if bad then those may be nightmares when we feel bad. Dreams are part of the unseen where devils or angels affect our mood, thoughts etc. and even the state of spirituality. Spiritual persons may see in dreams people whom they advise then in real life and sometimes dreams may bring two people together who have seen each other in the dream already and confess that in reality. Dreaming is a wonderful inspiration that is a kind of revelation from higher levels of being and correspondence that may be linked to religious teachings as by nature every person beliefs in something and that belief may be a dream as well. The fact that many books were historically written in the Islamic Civilisation of the Golden Ages reflects that much matters, items, persons that appear in dreams have a meaning in reality and must be understood with caution. It affects the psychology and life altogether. A wonderful thing to have dreams :)