If HIV is spread by intercourse, then it is completely under our control if diagnosed people just don't have sex. Why is that so hard? We could soon eradicate the disease from at least the developed world.
It's quite easy to be infected with HIV and not know it. HIV is notoriously stealthy, often producing no symptoms for months or even years, and in the meantime the person can transmit the disease. That scenario describes a large percentage of the people who have transmitted the disease.
Then there are the people who don't even know it exists, much less how to prevent it. A lot of the world isn't educated and doesn't have access to modern health care.
Intercourse isn't the only way to transmit it. Sharing needles is a common route of infection among drug addicts, and in third world countries where medical supplies are scarce, needles are sometimes reused. Infections have also occurred via organ donations, accidental exposure to body fluids (usually medical personnel), and from mother to child both in vitro and via breast milk.
Thousands of people died of AIDS due to HIV infections they acquired from blood transfusions and organ donations before HIV was recognized and screened for. That probably still happens in third world countries where they don't have the money or facilities to screen adequately.
And of course, there are the sociopaths who just don't care. There are people who know they are HIV+ and will still go out and have unprotected sex without informing their partners.
And finally, you might want to consult a few religions about convincing people not to have sex. Several of them have been trying to do that for thousands of years and every one of them has failed miserably.
So it's a nice idea, but it would take a large coordinated effort by most countries around the world (lasting many years and costing many billions) to eradicate it entirely. As you might imagine, the political, financial and logistical difficulties such a program faces are rather large.