I recently stumbled across an essay from 1946, by George Orwell. It describes his motives, and the motives he suspects are universal, in writing books. What's most interesting about the essay is his frank admission to the role of the writer's ego in the process. Here's an excerpt:
Putting aside the need to earn a living, I think there are four great motives for writing, at any rate for writing prose. They exist in different degrees in every writer, and in any one writer the proportions will vary from time to time, according to the atmosphere in which he is living. They are: (i) Sheer egoism. Desire to seem clever, to be talked about, to be remembered after death, to get your own back on the grown-ups who snubbed you in childhood, etc., etc. It is humbug to pretend this is not a motive, and a strong one. Writers share this characteristic with scientists, artists, politicians, lawyers, soldiers, successful businessmen — in short, with the whole top crust of humanity. The great mass of human beings are not acutely selfish. After the age of about thirty they almost abandon the sense of being individuals at all — and live chiefly for others, or are simply smothered under drudgery. But there is also the minority of gifted, willful people who are determined to live their own lives to the end, and writers belong in this class. Serious writers, I should say, are on the whole more vain and self-centered than journalists, though less interested in money.
Does this describe any writers you know? Read the whole essay for more on why Orwell wrote.