Why do they do it? Lots of reasons - social interaction, to build an online presence, to contribute to the community.
Mainly, though, it's all about the reputation, and getting points when someone marks your answer as correct, or "likes" your comment.
What does this have to do with you? Simple. If you have a technical problem that you've researched online and can't solve, go ahead and post a question on one of these sites. StackOverflow is my personal favorite.
Posting a good question, though, is a huge component of getting a good answer. Be sure to:
- Include a script to reproduce the specific problem that you are encountering. This includes all the data setup (tables, insert statements, etc)
- Carefully exclude everything that is not critical to explain your problem. I've seen lots of questions posted that include many extra columns, tables, etc, which didn't contribute to a reader's understanding of the problem. Including nonessentials actively works again the reader's understanding of the problem. They probably won't bother trying to figure it out. This step is time-consuming, but critical. And you may even figure out the problem yourself once you've cut it down to essentials.
- Include what you've tried so far and what research you've done.
For an example of a question presents a very straightforward picture, take a look at this StackOverflow question that I posted: Pivot query to return multiple repeating groups. Notice that I've included code that can be run with no modification, the desired output, and a potential solution that I'd like to improve on.
I got two great answers from this that the posters put a substantial amount of time into. Regardless of whether the answer works for me, I always put in a comment with some words of appreciation.
Here's a blog post I wrote recently: How to use a column name as an argument in a TOP clause. I wasn't looking for answers here, but this is a good example of taking out everything extraneous until you have just the core of the example. For instance, instead of using 2 columns, ID and a Name, I just use the name (for both the Customer table and the Market table), just to make the example easier to follow.