Good question! It would be wrong if I say reputation does not motivate for writing good answers but reputation is not the only factor that motivates to spend time putting efforts to write answers.
For new and establishing users, earning reputation means unlocking privileges. So, it develops curiosity for learning more how site works and moderated. Reputation is also defined as rough measurement of how much the community trusts you! So, community appreciates you.
Here are some factors that motivates me for writing answers.
Helping others and Learning topics
Why HSE exists: To provide expert answers. The prime objective of the site is to make the site knowledge base for visitors and users. Our efforts will never go in vain. In addition to the answer benefits the questioner, it benefits others also. Answers we write here are permanently gets stored in the database and can be found easily by simple web search becuse Stack Exchange sites are nicely indexed with search engines like Google. So this is for benefits of every people who are followers of Hinduism or Interested in learning Hinduism.
When you write well researched and detailed answer, you have to put lots of efforts searching, reading scriptures, getting the things, interpreting them and then writing answer. So, these activities will teach you many things. The time you spend will not go in vain, you learns something which is worthy. This will also make you to read some more (extra) stuffs, texts and probably search/ask questions! I remember almost every time I wrote detailed answers, I learned some things which triggered me to study some texts which results in gaining knowledge. So, this is for learning and gaining knowledge.
Noting down and sharing.
As already said, the answer written here is stored permanently, I sometimes write answers to keep some important topics stored which would be easily available from anywhere just by couple of clicks. Another advantage is you can easily share your post to others. If someone (your friends, colleagues etc.) gets similar question you can just share your answers to them which will save your time in explaining same thing again and again. So, this is one time investment! :)
Sometimes I posted self answered questions which will be useful in both ways noting down for self and sharing to others.