For me, writing is a passion. Not writing is an impossibility. There are stories in my mind; I need to tell them. I need to find out where they go, how they go, what they mean. I have something in mind when I start a story, but it changes, mutates, I do not fully understand it until it is written and finished.
I find out what I think and how I feel about complex issues (moral, philosophical, political) by writing about them, directly or indirectly. A story lets me ask complex "what if"s, that lead me deeper into an issue. I can play with ideas, explore them, travel down untrodden paths to find out what lies at their end.
Writing is a process, and I enjoy every bit of that process. The research, the editing, the sketching down of hasty ideas and drawing lines between them, the bouncing of ideas against longsuffering friends - every part of the process of creation. I love it, because it is a process of creation.
Of course I want an audience. A story is to be told to someone. Otherwise, is there a story? A story that isn't told is like sheet music that's never played - it is a promise unfulfilled. I am made uncomfortable by books that don't get opened - they are there to tell stories, not to sit on a shelf!
However, while I write, I do not ask myself whether this thing will get published. For one thing, I myself might decide that this half-finished creation project is not good, and consign it to the dark pit of oblivion in a "nah" folder. Multiple mythologies speak of the gods making multiple attempts and scraping them before arriving at a final creation. My story, my prerogative.
And then, the thing is, in our digital world there isn't really such a thing as "no-one will ever read this", unless that's the fate you yourself want for a particular story. You might be unable to sell it. You might be unable to have it published traditionally. I'm sure as heck going to try - like I said, I very much want an audience. But I do not look to earn my bread through writing. So if all else fails, I can just post my stuff on the web, and proceed to write the next thing.
Of course I'm learning and I'm getting better as I write. But honestly, that's not something I look at. I do not write now so that "one day" I can write better. I write because writing is a fire in my bones right now.