Would You Write If You Were Never Getting Published?" This question has its origins in the pre-self-publishing era, where the only way your story had a chance to reach the masses was through a publisher, and the odds of that happening were long (still are). If you are pursuing the trad-pub path and would never in a million years consider self-publishing, then the question still applies.
But with the advent of self-publishing as a viable (and increasingly respectable) way to reach readers, not only does the answer to that question change, but I think the question changes as well.
Changing the Answer
For people that consider self-publishing a viable option, the answer quickly becomes "yes," because self-publishing essentially guarantees that your work will be exposed to the world (whether it will sell is another question). Even if you consider self-publishing as a last resort, after trying the traditional path, there is no longer the prospect that you could spend months and years working on a manuscript, just to have no one (outside your critique group) read it. (Whether this is a good thing, or not, is a separate question - but it is at least an option.) So, the only reason your work will not get published is if you decide you do not want it to be published - an altogether different writing environment.
Changing the Question
In this environment, I think the question should be changed to, "Would You Write that Story If You Knew It Wouldn't Sell?"
Maybe you're working on your first novel, which you're convinced will be a self-published bestseller. If you knew ahead of time that it would tank and sell less than 100 copies, mostly to your mom's crochet group, who uses your novel to hold their skeins of yarn, would you still write it? Perhaps, because you have to write your first novel before you can write your second and third. But you might hesitate before publishing it.
Say you're a little further down the path. Maybe you've got a few novels under your belt, maybe some of them are even published, but you're itching to write the biography of an obscure Irish boxer from 1955, which you're convinced no one, absolutely no one, will buy. I mean, the market for that has to be infinitesimally small, right? (Even if you're a famous author.)
Would you still write it, if you knew it wouldn't sell?
This question becomes more than theoretical once you're past the thrill/rush/nausea of publishing your first (or second or third) novel. When you know you can write a novel and you can have it published, would you still write something if you thought it wouldn't sell (i.e. the market is small and/or unreachable for it)? I can see this question nagging both trad-pub and self-pub authors as they march down the path of their careers.
For me, this question illuminates the choice of what to write after my Mindjack series is done (in the next six months or so - what can I say? I like to plan ahead). I have a several ideas that I think will sell: a steampunk YA fantasy, another YA science fiction series, an adult SF novel. I also have an MG Fantasy that's already drafted that I love - but indie publishing isn't really ready for MG, and the traditional route still has long odds. Not zero odds, but much smaller than the chance that some of those other books have of selling in the indie market.
What would you do?
(p.s. my answer: write it anyway, for the love alone. Query it. If it doesn't sell there, indie publish and be happy with whatever few sales it makes, just to have it out in the world.)