I began writing 3 years ago because I was frustrated over how bad writing in anime was after watching Kill la Kill, and while that's cooled a bit, it's still a factor that keeps me going. I'm a very competitive person who can't stand not being good at something, so I tend to go extreme in to anything I do - reading hundreds of pages of literary criticism to become a better writer, testing new styles to improve, the frustration when something doesn't come to me and the reevaluation of what I've written. I'm a bit of a misanthrope, so I work very well out of spite - what drives you will depend on the type of person you are.
That isn't to say I don't love writing, though. It frustrates me that my own work will never be as popular as some crappy harem isekai, or the great cinema I've seen will never be as appreciated as Marvel, but when I wonder why I bother, I can at least sit in my satisfaction that I've created something good or better than the writing I hate. It's a bit of a superiority complex - it's tied closely to the misanthropy, so I not only want to be better, but I need to be better than the average writer. I have a friend who uses the same mindset for lifting weights - he can't stand being physically weak.
Is that an antisocial or unhealthy mindset? Sure, although I think my post history shows I do genuinely want to help people, and I don't enjoy being hurtful to others.
So I dunno, I guess you just have to find your own discipline/motivation for it. I wrote a lot of stories no one's ever seen, and I know my drive to improve is all internal, but I also love knowing someone out there will appreciate what I've done and the craft that goes in to what I do. This, I believe, is a difference between true quality and fun, but massively popular "lowest-common-denominator" art: many will like the latter, but very few will love it deeply. So I suppose I want to write not only for myself, but for the person out there that will say at the finale: "I really loved this story, but what was with all the KLK references? You must've been a big fan of that show."
That's my drive - I can't say what your's has to be. For me, it also helps that no one, really, is writing stories like mine - if I want to read it, I have to write it.
Barring that, this poem always deeply motivates me, somehow:
"There is the feeling beside that which is felt,
as if a great artwork beyond consciousness,
whether gazing a church tower, or being sifted through its panes
like alluvial photons. There in a bowl of opening roses,
made majestic by a slice of sight reflecting
the spoke of sun upon a slab where something dead may lay,
is an abstract of insight grown well within your wreath of verse,
brief episode of touch, still opening endlessly and growing,
self-illumined, silent paladins of the muse,
like nothing that ever was:
I know nothing of life."