You really have to write it for yourself if you want to keep going - unless you're lucky or have a large following already it's hard to get a lot of readers. I've written stories and serials and posted them on social media, my personal site, etc. (I release them as Creative Commons works) and few people read them. Self-published authors who want to make a living typically have to do a lot of promotion to get a chance.
Also there are times when I decide I want to read my own stuff for entertainment instead of a published novel. And the joy I get from that keeps me writing.
Many successful artists in any medium say they create things for themselves; it's more a compulsion than a business activity. Some are lucky that others like it; some are even luckier that others like it during the creator's lifetime; the luckiest even make money from it!
If you want to make money you're often creating for your audience rather than for yourself too. For instance I know professional artists who don't enjoy their work that much since they end up having to please the client rather than make what they really want. Even for my own CC fiction my themes and language are affected by current trends and what I think my readers will like. Of course if you're lucky you can create whatever you like and your fans will eat it up, but how many people can do that?
As an aside though I feel that the science/engineering heavy HN crowd would bring some life to science fiction. We have the ability to write things that make technical sense and I'm sure many of you internally roast the handwaviness seen in some franchises. I don't know if I'm the only one that does this but I plan out the computer networks my characters use, draw cutaways and chip architecture diagrams for new devices I come up with, read scientific papers for research, and so forth. Sometimes that's even more fun than the actual writing!
Cixin Liu was a computer engineer working at a power plant before writing 3 Body Problem and its sequels. He very clearly embeds his love for science into his books.
Also there are times when I decide I want to read my own stuff for entertainment instead of a published novel. And the joy I get from that keeps me writing.