Writing, like many creative outlets, allows you to exoricse thoughts through fantasy without actually having to act them out. Exercising speculation through fiction is a mental exercise that can help with problem solving in concurrent, real life events. Escapism can also have its uses dealing with day to day stress, just as writing out your thoughts in the form of a journal can help to validate painful emotions.
For me, writing is a way to express myself. I tend to bottle things up and hide them away, but some time that energy has to be released. It always varies on my mood or what's happened to what I write. Like right now, I don't know what I should feel or act like to the events of today, so I wrote a speech like thing for someone close to me that's passed, and it's helped.
I used writing as a way to escape reallity at the hardest of times in life. The devorice really changed the way I veiwed things and kinda brought me on to writing more and to really vent some of the anger and hate I had from that.