I do contribute to open-source, and for a couple reasons:
I am where I am today (job, education, skills) because I had access to great open-source software in the past. Since other open-source contributors contributed to my success, it's time for me to pay-it-forward and help those following behind me by doing the same.
I believe in “corporate stewardship” and the idea that businesses have a duty to invest in the communities where they operate and where their workers live, so as a self-employed worker I need to find 1-person-sized ways to give back to my community.
Sure it can be fun to hack on projects, but I don't have to share everything I make online. The reason I am motivated to share code is to help my peers, to help my industry, and to help those just starting out. If sharing my code can help save another person time, work, or headache - then it's all been worthwhile!