The history of this is really complex and would take a really long time to write out; however, the pre-HIV/AIDS era has a lot to do with the current epidemic.
I'm gonna try to keep this kosher.
Essentially, for gay/bi men and preop transwomen, if you want to achieve penetration, you have to use the anal passage. The rectal walls are much more likely to tear, exposing participants to the virus both ways, assuming its presence. A condom goes a long way in stopping this flow of the virus, but even they have their limits. It's just a risk you take.