Apple Inc.’s $1 billion investment in Chinese ride-sharing company Didi Chuxing Technology Co. reflects an intensifying battle over the future of driving and highlights emerging alliances among auto makers, technology firms and ride-sharing companies.

The competition to build and provide autonomous vehicles promises to pit the world’s two most valuable companies, Apple and Google parent Alphabet Inc., among others, against one another and against the world’s most valuable private venture-capital-backed company, Didi rival...