What he did shows he's very selfish and not very considerate of your feelings. It's your boyfriend and you should be able to do with your boyfriend as you please. Clearly the boy still has issues and he's using you (manipulating you) not to move on too so he will feel better.
He may have rejected you but he's not allowing you to live your life either. This isn't love, not even friendship. Not unless he has good reasons for not liking your boyfriend which you don't mention and he doesn't seem to have. What does he even know, you haven't seen him for years.
I mean, seriously, having sex with someone isn't the end of the world and even though you can't undo that but why is that any of his concern? To knock at your door like that isn't right and you're being played, intentionally or not. You should tell this guy to mind his own business.
He might have been your first love, but that doesn't mean you should allow him to manipulate you like that. Begging you not to have sex in a relationship with your boyfriend? Really? Him being abused is no excuse for him to pull this **** on you nor should you allow it. If you do he'll only come back and do that again and again, hurting you again and again in the process.
Advise him to get help getting himself and his life in order, but ask him to leave you be. He didn't want you so now he has to live with that. Your current boyfriend makes you happy so make the best out of it. Don't bring this type of drama in your life. You don't need it and you won't help your ex crush with it either. So tell him to get himself sorted and show him the door.