You’ve hinted at many reasons your boyfriend isn’t enjoying sex. It hurts. He has a history with unsatisfying sex. His irritability may be a sign of depression, or it may be a sign that he is feeling pressure from you and from himself about being more sexual than he wants to be. In addition, at 17, he may not feel confident about himself as a sexual partner and he may not be ready for that level of intimacy with you.
I think your emphasis on sex is misplaced. It sounds to me like the way to become closer is to increase loving attention and your intimacy as a couple before getting so concerned about sex. That means just enjoying each other’s company. It means sharing what is most important to you. It means enjoying kisses and back rubs and safe and leisurely touch. Sex usually follows naturally when a couple feels safe, close, and loving.
In addition, your boyfriend should see a doctor about the injury, just to make sure there isn’t an infection. If he isn’t getting at least 8 hours of sleep a night, his irritability may only be about that. But if he is getting good sleep, then his tiredness and irritability may be a sign of depression. In that case, he could benefit from seeing a counselor. Regardless, what he needs most from you is to back off from sex and focus on love and intimacy.
I wish you well.