Dreams are often "internal movies" that portray the thoughts and feelings of your subconscious mind at the time of the dream. A dream is often a snapshot of your current or recent life, or one aspect of your life, portrayed the way your subconscious mind sees it. Often the subconscious mind will create a visual story using symbols that represent your deepest thoughts and feelings at the time of the dream.
There are many theories about why we dream, but no one knows for sure. It would make sense that the subconscious mind would use dreams as a way to "think through" important matters or problems, to analyze potential problems or dangers, or replay past pleasant experiences or create new ones. This makes good use of our sleep time while the body rests.
Often, the meaning of a dream is much different than the obvious meaning of events in the dream. For example, a dream that you have lost your keys most likely has nothing to do with actually losing your keys, but probably has to do with a feeling of losing touch with your self-identity and who you really are.