Don't stop there. Diego Garcia and the surrounding Chagos islands were ethnically-cleansed by a joint American-British operation just 50 years ago [1], to make living-space for this military base.
To be fair the just scooped the Chagossians out, whereas ethnic cleansing usually refers to extermination. Those who ended up in the UK have been fighting a legal battle since and seem to be making slow progress. From the British point of view it was a slam dunk, since they didn't care about the "man Fridays" and they got trident missiles in return.
You may want to check your definitions. This is a clear example of ethnic cleansing and should not be minimized just because it isn't literal genocide.
The issue of the Chagos Islands was the subject of an International Court of Justice advisory opinion which concluded that 'the United Kingdom’s continued administration of the Chagos Archipelago “constitutes a wrongful act entailing the international responsibility of that State”, that the United Kingdom “has an obligation to bring to an end its administration of the Chagos Archipelago as rapidly as possible, and that all Member States must co-operate with the United Nations to complete the decolonization of Mauritius' [0].
This one probably had more to do with protecting shipping lanes from French interdiction, given the location and which other countries had colonies and other operations semi-nearby (spoiler alert: France). As far as why the British cared to hold it in the last century, I mean, not for why it's still a base now. Leave all the islands in that area to France and it'd have been a dagger pointed at shipping crossing the Indian ocean via the canal. Seize a couple of the islands yourself, and at least you can keep an eye on things and mount a plausible threat if a hot war breaks out, to keep France from getting too bold with their use of the nearby islands.
Britain had a bunch of other islands much closer to India. Not even counting Sri Lanka.
Though, yes, protecting shipping lanes to and from India would have been part of the purpose, but not just to India. British Malaysia, various Pacific territories, and the commonwealth states of Australia and New Zealand, would have shared those same shipping routes, largely.
I'd guess that as a US base it's more likely to support US or NATO operations, real or hypothetical, in or around the Horn of Africa than it is to have much to do with the subcontinent.
For the US timeframe, the island was viewed during the Cold War as strategic to the United States, due to it's proximity to India, a potential ally of the Soviet Union. It served (and may still serve) as a Navy communication station. It has been used to monitor Afghanistan and China's activities in the South China Sea.
[1] - https://en.wikipedia.org/wiki/Stealing_a_Nation