Even if Mercury's HIV had been detected early enough, say the time range of 1977-1982, would the medications needed to treat it have been developed at the time?
There was AZT from the mid-1980s on, but as the Concorde studies of the early 1990s demonstrated AZT by itself was only enough to delay the progression towards AIDS by months, as the HIV in the patient's bloodstream simply mutated to minimize the effects of the drug. The paradigm now in place, of treatment with multiple drugs attacking HIV, using multiple different drugs each with different mechanisms of attacking the virus, could not have been supported by the drugs available at the time.
Freddie Mercury seems to have had no problems accessing treatment. He seems to have been well-connected, and he certainly was not lacking in the money needed. There was simply nothing that could be done.
I've touched upon this at an answer in Quora.
https://www.quora.com/What-if-Freddie-Mercury-was-still-alive-today/answer/Randy-McDonald
The only way for him to have been spared death from AIDS would have been for him to not be infected in the first place. He could do this--most queer men alive and active in the 1970s did not die of AIDS--but it would require significant changes, a break from his lifestyle. Was he in an authentically monogamous relationship, whether with an opposite-sex partner or a same-sex partner, one that lasted at least until the danger of AIDS became clear? Had he the chance to meet an early AIDS victim and be forewarned? If, as some suggest, he was only infected in the summer of 1982, there might possibly have been a window for him to be informed and to change his behaviour.
The only other way, I suppose, would have been for the field of antiretroviral medicine to be at least five years more advanced than OTL. I have no idea how this can be achieved, especially considering that the very idea of retroviruses capable of infecting human beings and causing disease was only discovered in the mid-1970s with HTLV.