Major Edit: Corrected extremely incorrect stats
The vagina, being "designed" (evolutionary speaking) for intercourse, has a lining which is reasonably good at fending off pathogens, particularly viruses like HIV. If there are no breaks in this lining (such as from rough sex), the risk of contracting HIV from a single sexual encounter with someone with a high viral load (ie. Lots of virus in their blood, and thus lots to pass on in their other bodily fluids) isn't as high as one might expect. That clearly isn't low enough to condone risky behaviour, but it's enough to affect the spread of the disease, especially because, like many STDs, HIV is more often spread through one-time sexual encounters (mainly casual sex and prostitution) than within a committed relationship.
In contrast, the rectum (the anus is just the opening; the rectum is the actual part of the gut inside) is not "designed" for intercourse, and has very poor defenses against pathogens. The risk of the receptive partner in anal sex contracting HIV from a penetrating partner with a high viral load is an order of magnitude higher than from vaginally intercourse
Finally, because of the lack of natural lubrication in the rectum and anal orifice, anal sex is much more likely to result in (minor) damage to the penetrating partner's penis, which increases the risk of the penetrating partner contracting HIV.
In short:
The rectum does not contain substantially more HIV particles than the vagina; but
The rectum is more vulnerable to infection by the HI virus, and
Anal sex is more likely to be "rough" on the penetrating partner's penis, making the penis more vulnerable to infection by the virus as well.
Thus, anal sex (regardless of the sex/gender of the participants) has a much higher risk of HIV transmission to the receptive partner, and a less elevated but still increased risk of transmission to the penetrating partner.
This may be part of the reason that HIV was once much more common in the homosexual population. The main reason, though, is that homosexuals and heterosexuals (by definition) don't often have sexual contact with each other, and bisexuality was quite rare in the era when HIV first emerged.
Most likely, a gay man happened to contract the virus relatively early in its spread (ie. Before it was widespread), purely by chance, and it just took a while for it to "cross the gap" into the heterosexual population.
Source:
Patel, P., Borkowf, C., Brooks, J., Lasry, A., Lansky, A. and Mermin, J. (2014). Estimating per-act HIV transmission risk. AIDS, 28(10), pp.1509-1519.