I want to add 2 different/extra motivations to the other answers.
Some people want to give back and not 'leach' the community:
asking/answering questions is not the only way one can help or
participate in the community.
Also, when a member doesn't have the time or doesn't feel qualified to contribute in the form of answers, they still get a visual indication (to the community) that they DO help out!
Governed by general rules and guidelines from SO, this Q&A site is largely moderated by the community.
That makes SO a sort of democracy. (Especially regarding 'Close' and 'Reopen' votes.)
At some point in time there was (well, it still exists) another very popular Q&A platform; however it was moderated by a (relatively) small group of people (often/mostly on the publisher's payroll) who
- 'drowned' in the amount of content to moderate (as the site's popularity grew), leading to a mess over time
- weren't necessarily qualified to assess value of content
- very often disregarded their own 'rules' and 'community-ethic' in favor of pure financial motivations (asking questions usually earned the company cash (for example, disallowed exact duplicates were more than welcome), although one could earn a subscription (by answering questions) payed with their 'equivalent' of 'rep-points' effectively making it into a form of currency (as opposed to SO's rep)).
- often (sometimes quite harshly) disregarded valid complaints about their (colleague's) moderation (or the fundamental flaws of their ambiguous policy that inevitably would lead to the site's down-fall.)
Ultimately this both drove away their bread and butter (the experts who actually answered questions) and killed the idea of a central know-how DB. That kind of left a relatively small core of altruists that provided the knowhow/answers/solutions, who subsequently drowned in the 'workload'.
And no more bread and butter means no more paying customers. In a desperate attempt to save their income, the brilliant idea to bury their (rather huge) library of know-how under a lead dome (even google link-through access no longer displayed solutions) killed their google-ranking and subsequently ad-revenue.
This is what makes SO so fundamentally different: it basically solved the root(s) of the above problems. In order to do that one needs co-operation of the community, which in turn wants to be treated fair (and not subjected to a late-hour frustrated judgment-call from one person (with optional agenda)), which can only happen in an open democracy. Heck, we even have meta..
Also, the ability to improve/update (links for example) content on our 'shared programmers notebook' is an incredible valuable feature, but it can only exist if we share the resulting workload of validating the edits!
I'm grateful for other peers safeguarding (my) content, expressing that gratefulness can be simply done by sharing some of that workload.
The benefits are probably the same as the reasons for voting in a democratic country; ultimately a form of self-interest.
I want SO to continue to survive and flourish so that I can still access it's (growing) wealth tomorrow!
I remember there was a day that SO was down (and it was known it would be for the rest of the day) and there were a lot of reports of programmers going home for the rest of the day.
Also, if nobody with the same preferences and ideas as mine 'speaks up', nobody would know those ideas might even reflect a democratic majority.