Dreams are a whole study I need to do sometime. The "basic" idea of dreams is - they are a jumbled collection of data in our minds from things we have seen in real life and watched in movies or television, etc. While we are asleep these images are cast up on the "video screen" of our mind and we see them. At times they seem so real. That is why we might wakeup afraid, in a sweat, etc. because the dream seemed so real. I had one such dream recently and was glad when I woke up to realize it was only a dream. I get dreams like that sometime when I take Tylenol before going to bed.
However, there are other dreams that are too specific and detailed to fit into this "basic" explanation. We also know that God has used (and many time still does use) dreams to communicate. We just need some clear assurances when He is communicating in this way.