There are probably as many answers as there are writers.
At one end of the spectrum are those for whom it’s just a job—a way to make a living—a business. For those at the other end, it’s an art—self-expression—a creative outlet.
Those at the “business” end of the spectrum don’t always care what they write so long as it makes money. Those at the other end write whatever they want and don’t much care if they get paid for it. I have known both types and, at the extremes, each type seems equal in its disdain for the other.
As is usually the case in life, I believe there’s a middle ground. Getting paid for what you write is not necessarily “prostituting your art.” Nor is putting art before commerce always unrealistically idealistic.
In fact, I believe most writers, in their heart of hearts, are driven to some extent by idealism—the urge to create something beautiful, original, and self-satisfying. And they work to develop the skills that allow them to do so. If they can sell it, so much the better. So we search for that point somewhere toward the middle, where the scales balance.
Then again, what do I know?
For decades, I have worked at a different kind of writing—advertising copy—penning innumerable words whose sole purpose is persuading people to part with money. And getting paid to write it.
The other stuff I write these days—poems, short stories, novels, history, essays, magazine articles—I write because I want to, and it doesn’t pay nearly as well.
Call me crass, but even though I don’t write that stuff just to make money I wouldn’t mind it one bit if more people were willing to part with their money to read it.