As someone who writes open source software to help solve other peoples' problems, all I can tell you is that it makes me happy to help other people. There's no logical reasoning behind it beyond that I feel good when I've helped someone else accomplish their goals.
Sure, you could analyze the cost and benefits of it, and maybe even find a logical reason as to why it makes me happy, but _I_ didn't. I just enjoy it! :D
That's the point - you do what you want because you enjoy it. I program because I like programming and I enjoy solving the problems people I like have. Solving a lack of enjoyment is solving a problem.
But I don't enjoy programming for people I don't like.
Sure, you could analyze the cost and benefits of it, and maybe even find a logical reason as to why it makes me happy, but _I_ didn't. I just enjoy it! :D