Top law firms helped the iPhone maker – and other multinationals – to navigate tax avoidance strategies around the world.