"By looking at the genome sequences of different viruses over time, researchers can calibrate a “molecular clock” based on the rate of sequence change, or mutations. Scientists can then use this to infer the rate of evolution and thus determine approximately when the most recent common ancestor existed.
Using this technique, researchers estimated that HIV-1 group M originated in 1908 and group O in 1920. HIV-2 groups A and B originated a bit later; approximately in 1940 and 1945, respectively."
"The simplest explanation is that humans came into contact with the blood or other secretions of infected primates which is perfectly plausible since, for example, sooty mangabeys were both kept as pets and slaughtered for bushmeat in West Africa, the same region that HIV-2 is most prevalent. It would be easy for infected bodily fluids to come into contact with broken skin during the butchering process.
Given the fact that medical resources are costly, it is plausible that during immunization programs in Africa, healthcare professionals would have shared needles, providing ample opportunity to spread infection through the population. This, coupled with an increase in international travel alongside sexual promiscuity and intravenous drug use, seems a logical explanation for the emergence of HIV.
Another theory is that humans became infected from contaminated oral polio vaccines. The vaccine in question was called CHAT which required the use of living tissue for production. The idea was that the kidney cells used in the production line came from SIV infected chimps and thus a large number of people were exposed. However, this theory falls down because as we have seen, not all of the HIVs came from chimps. It’s also extremely unlikely that oral vaccines would result in transmission since, unless compromised, the mouth is a pretty good barrier to infection. Furthermore, researchers found stocks of the vaccine used and when it was tested, no traces of SIV were found. This theory has therefore largely been refuted."
http://www.iflscience.com/health-and-medicine/where-did-hiv-come/