Back when the idea of a corporation was first formed (I do not remember the time frame) one of the requirements to complete the process of incorporation was to prove what you were going to do for the community around you.
Companies are usually improving the community in some way (that's why they make money in the first place). Grocers sell food to the community, hardware stores sell tools and supplies for making things, even the dreaded oil companies have sold the primary source of fuel for a century (and made money hand-over-fist for it). Random acts of kindness (e.g. open sourcing projects for no reason other than "We could"), while cool, are tangential to the purpose and specialty of the company.
This is how it should be - sadly both ends (doing good and making money) are not always aligned with each other. From my personal observation I would say that they are less and less aligned the bigger the company is.
Back when the idea of a corporation was first formed (I do not remember the time frame) one of the requirements to complete the process of incorporation was to prove what you were going to do for the community around you.
I wonder how this idea got lost in the process...