I wished I could recall who said it so I could give proper credit, but I am certain that others have touched upon the answer or at least close enough to it.
Agents, authors, author wannabes, and readers have often asked the question (maybe for ice-breakers in a conversation, blog, or tweet), "Why do you write?"
Some answers are generic and common, "I cannot not write," or "I have to write," and maybe, "I love writing for writing's sake"...and the list goes on.
One writer (I am sure he was a well-established successful author from somewhere in history - either recent or ancient), said, "If you are not writing to be published, then why are you writing?" (of course that is not a direct quote because if I could recall it verbatim, I would remember his name, right?) Writers write to be read, which usually includes some form of publishing whether it be traditional, indie, or self.
One person has read my recent novel, Encore, all the way to the end. Mission accomplished. She wasn't even my targeted audience, but she loved the book so much that she talks about the characters as if they are real people, and she wants a sequel. I know some more people are reading it now, but she was the first to buy it and read it.
Seeking publishing in any manner, is not vain nor is it selfish. On the contrary, how else could we share what we have labored over to produce?
We don't write just to stash our novels, poetry, stories, or memoirs inside a closet for someone to discover when we die. If we die in a house fire taking our hard work with us up in smoke, no one would ever know we wrote a single thing. We don't write to hide it in a vault for our own satisfaction.
We write to be read.