Is there a legal or economic basis for saying that companies must be unethical to profit?
Economically speaking, the contrary is true. The belief that profits are unethical created 50 years of economic misery in India. Before the reform of 1991, the draconian system of regulation meant you effectively needed license to profit, which the government gave but rarely.
The profit-is-ripoff interpretation -- which is still widespread in India -- comes from thinking of the market as a zero-sum game, which it is not. The power of the free market is contained in the moment where the seller and the buyer say to each other "Thank you - Thank you." Both gain from the trade. More importantly, the advantage to the buyer exists regardless of the profit margin of the seller.
Back in Montréal, there was a restaurant around the corner from work that used to serve me launch for 8$. I ate there every day because no other 8$ expense brought me as much joy. Perhaps if they had refused to make a profit lunch would be 6$. It would have been 4$ if the restaurant that refused to pay its employees -- to give them their part of the profit. It would be 2$ if the farmers were farming for fun. And so on. But that's neither here nor there. The transaction was advantageous to me at its stated price, otherwise I would not have entered into it.
Even though the restaurant was clearly profitable, I don't think anyone would call it a rip off (the food was excellent). To define ripoff, you have to look elsewhere.
There are companies that maximize their profit by amplifying market failures. Stadiums refuse outside food so visitor are locked-in to the concessions. Music producers organized an oligopoly so they could go price-fixing. Users of DRM aim to undermine libraries and secondhand bookstores. By doing this, they deny society of the advantages of a free market. It is unethical, and often illegal. The market distortions observed in these cases are the real ripoff.
India's confusion between profits and market failures had grave consequences. Interestingly, the United States has the same confusion, but backward. By celebrating profit as a force of good, and refusing to regulate, they are giving free rein to market failures. It caused Enron, the subprime collapse, of the sorry state of its cell phone market when compared to Europe or Japan.
It's illegal for a corporation to behave in a socially responsible way -- unless that socially responsible behavior happens to be identical to the behavior that maximizes profit?
It is certainly legal for a company to declare in their charter that their objective is not profit maximization, so long as the stockholders know what they are getting into. In practice this hardly matters. Most companies' charter promises to maximize profit, and so they are required act accordingly. Corporate Social Responsibility policies are common because they coincide with profits. Badly behaved companies lose their market share once their behavior is uncovered to the public. In the imaginary ideal market, with perfect information, the backlash is immediate. (Thus one strategy is to regulate towards more information.)
I believe that on the whole humans are a constructive force, and would rather not oppress each other when given the chance. I would rather pay more for coffee than have it processed by children. The arrival of the Fair Trade label, despite all its shortcomings, gave me a way to express that intent. Unfortunately, the finance world has no such mechanism. I own stocks through my investments in mutual funds. I may be unhappy with their profit maximization objective, but I am voiceless.
So, yes, the original criticism of corporations stands. While some company are founded by dangerous individuals, and do not need external help to misbehave, the legal structure of the stock market divides us, and will at time oblige respectable people to behave against their ethics.