Apple Inc.’s Chief Executive Tim Cook defended globalization in a rare public speech in China, as his company faces political pressure in the U.S. to bring back factories. Mr. Cook said in his hourlong session that globalization “in general is great for the world,” but gains aren’t evenly distributed within countries. While he said this was a problem, he cautioned against countries retreating from globalization as a response.