Tim Cook’s era at Apple is coming to a close. Here’s how his impact will be remembered—and what John Ternus needs to tackle first.