My comment is too long, so I'm going to post it in two parts.
First, I want to point out that you're right. It is true when you say, "Companies aren't public to be nice." That's true and I'm not going to argue that. The fact is, they aren't.
However, that's not how it has always been. I'm not really able to find any good citations so I'm taking a little time to make something for you.
It's important to understand the history of incorporation. To be incorporated (thus traded publicly) confers certain rights to a body of people.
I know, people complain about Citizens United and how "corporations are people." But, that's actually pretty much always been true.
"Corporations are invariably classified as "legal persons" by all modern systems of law, meaning that like natural persons, they may acquire rights and duties." [1]
Because of this notion, once upon a time, the right to incorporate was controlled by the State.
"At the Declaration of Independence, corporations had been unlawful without explicit authorization in a Royal Charter or an Act of Parliament of the United Kingdom." [2]
In other words, the State controlled the ability to incorporate - in this case it was the monarchy. You needed a royal charter, at the least. (We still use the word charter.)
Now, here's the kicker... We wanted to establish the right for a group of individuals to incorporate. We'd already decided that representative groups were a right (the right to peacefully assemble is a good indicator) and so we decided that we wanted to allow more freedom to incorporate.
But, we knew that incorporation could lead to some negative consequences. The founders were pretty smart, in some ways.
We also knew that the Federal Government was capable of being too large. This is a subject of great depth and we'll not get into it. Suffice to say, people aren't actually always being racists when they assert the importance of State's Rights.
One of the earliest concerns about State Rights was actually about incorporation. The Feds had decided that a group of people had a right to incorporate without actually residing in the State they'd chosen to incorporate in.
So, this led to many things but we're only concerned with one aspect. (I'm trying to be brief.)
Namely, we didn't just want people to have the ability to incorporate without any controls. We still wanted government oversight and we still wanted to ensure that incorporated entities were a benefit to the public.
So, back then - and in certain States (I'm unable to find an exact number in the time I've allowed myself to make this post), to incorporate actually required both introduction and vote on the Senate floor.
"Prior to the late 19th century, most companies were incorporated by a special bill adopted by legislature." [3]
By now, you're probably wondering what the whole point is of this wall of text, seemingly from a mad man. Well, I'm getting to that.
So, way back then, we had the legislature approving of each individual group that sought to incorporate. On top of that, they were very willing and able to revoke their charter and to dissolve their corporation.
"Early state corporation laws were all restrictive in design, often with the intention of preventing corporations for gaining too much wealth and power." [4]
In other words, one of the absolute principles for founding a corporation was that it must be of benefit to the public. A corporation had to start and maintain their good to the public. A corporation had to provide a public good, they had to benefit the public, they had to be good stewards and citizens. That was explicitly what they had to do.
So, you're right. Corporations don't have to be "nice." However, they used to have to be "nice." They used to have to be beneficial to the greater society. They had an obligation - because they were conferred rights they'd not normally have. To incorporate absolved the individual, and the shareholder, from many legal responsibilities and, in exchange, we (via our elected representatives) insisted that they provide a benefit to society as a whole.
I'd think that qualifies as "nice." Don't you?
Anyhow, we maintained this for quite some time. We enforced this with things like the Sherman Antitrust Act [5] and other such legislation. The Sherman Antitrust act is an important indicator of the obligations of corporations. This was better explained in 1993 in Spectrum Sports v. McQuillan [6] which explained it thusly:
"The purpose of the [Sherman] Act is not to protect businesses from the working of the market; it is to protect the public from the failure of the market. The law directs itself not against conduct which is competitive, even severely so, but against conduct which unfairly tends to destroy competition itself." [7]
Again, you're right! I'm absolutely not arguing with you. A company isn't public to be nice. However, it doesn't have to be that way - and it hasn't always been that way. There's absolutely no reason why a corporation should be allowed to exist if it is not, in fact, benefiting the public good.