Legal BEPS exist and is more complicated than this oversimplification. While Apple didn't do Stanley Works "moving" to Bermuda, Tim Cook is no slouch in the
financial domain as that was (and is) his wheelhouse. The calculus involves a myriad of factors including a risk appetite, leadership ethics, lots of data, and decision support. As an aside, I once parted ways with 2 potential business partners because they were on the privately-admitted
illegal side of BEPS and tax minimization in speech and action. (Last I heard, they're lobbyists for political interests based in another country.)
Also, the books for taxes and the books for securities regulators aren't precisely equivalent per jurisdiction based on how things are counted or not counted. For example, in general, Norwegian and US accounting practices tended to be/are vastly different in some areas... hence a need for local external auditors.
Corporate Inversions: Stanley Works and the Lure of Tax Havens (2002)
https://www.hbs.edu/faculty/Pages/item.aspx?num=29288