" Companies are required by law in most places to maximise profits."
I believe the correct phrase is "maximise shareholder value", not maximise profits.
This is a very different thing, as the turn is user definable - Network Rail for instance is non-profit, it maximises shareholder value by putting earnings back into the railway network (its Shareholders being the Train Operating Companies).
Another company might "maximise value" by turning away some business to build an aura of exclusivity - trading tangiable value (revenue) for an intangiable result (Branding).
Some might play the short game (sell poor quality as quick as possible then skip town) where as others might play the long game (earn a little less now, but build long term loyalty).
If the law was maximise profits, then companies would never be able to give to charity, and rarely be able to sponsor sports teams. You might consider the latter to be preferable though :p