It's strange to me that Friedman is viewed (at least by economists and "business" folk) as a paragon of logical reasoning and empiricism, all the while his views reek so strongly of ideology. There are tons of reasons why the quoted statement might be false whether you're a policy maker (negative externalities) or even the most cold-hearted capitalist (short-term incentives).
Perhaps relatedly, it's actually not true that corporate responsibility to profit is codified in the law. See e.g. https://www.amazon.co.uk/Shareholder-Value-Myth-Shareholders...)