Some people with mental illness live in imaginary world. They have created an imaginary world in their mind and they have succeeded in turning this to their reality forgetting their true reality.
For example, someone with schizophrenia can be delusional, believing what is unreal as real.
This can be properly handled and treated with the help of professionals in this field.
There are some people who opt to live in imaginary worlds in order to escape the type of world that they are living in right now. There are some people who have been traumatized or hurt too much that they have decided that they only way they can cope is by not accepting the truth.
This type of condition can be cured with proper therapy and the support of other people who care for the person. Daydreaming is not a sign of mental disorder. People daydream from time to time. What makes escaping to an imaginary world a mental disorder when people begin to believe that the imaginary world is a reality.