even if the responsibility is to maximise profits, nothing in that says that it's to maximise _short_term_ profits. In fact, frequently things that maximise short term profits hurt you in the long term.
goodwill is one of those things that sacrificing for short term profits will hurt you in the long term.
In any case, the mission of a public company is not to make profits, it's to do whatever the company charter says the company does.
If the company charter says that the mission of the company is to break-even or produce a modest profit while producing the most public good, then the company is not a non-profit, but at the same time, if the company directors start making decisions to maximise profits they are working against the company charter and are in violation of the law.
Yes, some companies have their charter say that they are in business to make as much money as they can, but that's not all companies. In google's case there is the famous "Do no Evil" statement, and while there can be disagreement on exactly what that means, one thing that it clearly DOES mean is that google doesn't prioritise making money over every other consideration, and if any company directors started doing so, they are breaking the law.