Dreams can be a key to self-knowledge in that we can where certain ideas come from. Sometimes by remembering what was going on in our life at a past time, we can understand why we came to believe a certain thing. Subsequent experience, knowledge or whatever may change that. It is important to remember that dreams are people-specific, and the same dream will mean something totally different to different people. Some other small parts control stuff like balancing when we walk, breathing, heartbeat, changing light to vision, sound to hearing, and so on.
Imagination is used in more then dreaming.
For example the ancients seen figures in the constellation such as Andromeda, Orion and like that. A favorite childhood activity is to look at clouds and see shapes. The mind cannot deal with chaos very well, and often make order of things that really have on order. This is also important to the dreaming process. And occupies a lot of the brains resources.