The United Kingdom's position is that it is abiding by the 1965 Lancaster House Undertakings which resulted from talks between representatives from the UK and Mauritius, as well as the 1966 agreement with the US. Ceding the territory to the US, or to any state, for that matter, would appear to constitute a breach of these agreements.
One of the Lancaster House Undertakings - which are laid out in paragraph 74 of the report from a 2015 UN convention on the law of the sea tribunal - was to return the Chagos Islands to Mauritius when the territory is no longer required for defence purposes. The UK's position on these undertakings was laid out by then Minister for Europe and the Americas, Sir Alan Duncan, in July 2019:
Mauritius entered that agreement in return for certain benefits,
including a sum of £3 million and a UK commitment to cede the
territory when it is no longer needed for defence purposes. That UK
commitment still stands. Mauritius affirmed the 1965 agreement
numerous times following independence, and the agreement was held to
be legally binding by a UN convention on the law of the sea tribunal
in 2015. No international court or tribunal has ever found our
sovereignty to be in doubt.
Ceding the territory to the United States would, presumably, render the UK unable to abide by this commitment.
Furthermore, the UK also agreed on a treaty in 1966 with the US which states:
(1) The Territory shall remain under United Kingdom sovereignty.
...
(11) The United States Government and the United Kingdom Government
contemplate that the islands shall remain available to meet the possible defense
needs of the two Governments for an indefinitely long period. Accordingly,
after an initial period of 50 years this Agreement shall continue in force for a further
period of twenty years unless, not more than two years before the end of the initial period, either Government shall have given notice of termination to the other,
in which case this Agreement shall terminate two years from the date of such
notice.
As no such notice of termination was given, according to Sir Alan, this represents a "binding treaty obligation to maintain UK sovereignty over the whole territory until at least 2036."