How does our mind make dreams when we sleep?

There are several theories about what causes dreaming. One is discussed in this article:

http://www.members.cox.net/dagershaw/lol/DreamsReveal.html

I hope this helps. Thanks for asking.