Tim Cook explained how he chose to join Apple when it was still struggling. It’s a masterclass in making tough calls.