One property of dreams, which you have when you sleep, is that they are not real but imaginary, and thus may give you unlikely experiences.
In many languages throughout the world, not limited to English, you express your wishes you think are perfect (“ideal”), your ultimate desires, with the word “dream,” which means “an (unrealistic, unlikely, and impossible) imagination you get when you sleep.”
Why is that, despite those negative connotations?