Is world is just an output of imagination? and all the people (family, friends) are an output of imagination and not real? If yes, how it happens, when and why this imagination occurs.
Is world an output of imagination?
No, the world is real and a creation of Brahman for the Jivas to experience their karma, which is also real.
This entire theory rests on a fictitious foundation of altogether hollow and vicious arguments, incapable of being stated in definite logical alternatives, and devised by men who are destitute of those particular qualities which cause individuals to be chosen by the Supreme Person revealed in the Upanishads; whose intellects are darkened by the impression of beginningless evil; and who thus have no insight into the nature of words and sentences, into the real purport conveyed by them, and into the procedure of sound argumentation, with all its methods depending on perception and the other instruments of right knowledge. The theory therefore must needs be rejected by all those who, through texts, perception and the other means of knowledge--assisted by sound reasoning--have an insight into the true nature of things.