Do I put my emotional and mental health first?
You aren't good for anybody if you are in a situation where you are being bogged down, made to feel less-than, and unsupported to grow into other areas of life. Look, being a man, and being honest with you, "flirting" isn't harmless. It's insidious how the mind works; we cross a line a little bit, then a little more, then a little more, always aware of what we are doing, but getting better at justifying our actions. Certain thoughts from your boyfriend might be, "oh, we are just friends." Or, "Well, I didn't sleep with them." Maybe a point of argument could be placed on you, that "you are just jealous." Even if none of these have actually been spoken about, the best-case scenario is that they have been conceived.
The reason I say, "best case" is because if your boyfriend is engaging in flirtatious behavior and doesn't have to justify it, it means he genuinely doesn't see anything wrong with it, and that shows a deep belief in his lack of respect for you and your feelings. Even though ignorance can gain a pass when revealed for what it is, that he, "didn't know," it still leaves the question of what are you going to do with a man like that. Are you willing to teach him and work with him through it if willing? You mention it has already been five years. How much are you willing to accept that the best the relationship can get is with someone who doesn't know better, or if he does, justifies it? If he isn't willing to work on this or sees it as his weakness, what are you left with but settling for the less than? You, too, will have to accept you are less than, because a weak or unconfident man cannot be with a strong confident woman, and ma'am, he does seem weak.
Flirting is Weakness
Flirting is validation. Flirting is admitting that though I am in a committed relationship and have a child I could invest in, I would rather get the attention of these women. Someone like that needs it to feel good about himself. a man like that has a shallow self-image, one requiring another's validation of him, which he manipulates to be viewed as adequate.
Not to speculate too much, but in my experience, his not engaging in any extra relational affairs is because the women won't go that far, and he is a coward. That's what happens with weak men, though. They are scared of getting in trouble or being embarrassed. Don't mistake his not cheating as being a good man, but take it as cowardice. Unless he is willing to do what is necessary on some interpersonal work, see a therapist, deal with the inadequate self, admit that he feels inadequate, etc., could stuff get better. If he isn't willing to do that or go there with it, he isn't going to change, and the behaviors get worse as he gets fed up, gets bolder, better at flirting, and then one day goes too far physically with someone.
Look for these signs.
If you tell him these things I am saying and he gets angry, and says it's not true, you have to then notice that he became angry, because....? Why do people get angry? This is usually from a place of hurt. Why do people get defensive, justify, and blame, because they are victims, and a victim makes everyone and everything their persecutor. None of this is about you doing better or me not saying anything, but it is about him being able to admit the nature of his actions and not admitting the actions.
Now, the part you play, if he can confess the nature of his sins, is if you have been disengaged as well. Or, if he reports that you don't seem to care or something to show he's not feeling connected to you. I don't mean that he is right if he blames you for what he has done, but there could be some truth there. Unfortunately, the truth could be that you are confident and willing to leave; he knows you could do better (mostly because of his poor self-perspective) and therefore wants to break you down. There is always truth in what someone says, but take it in context. If one cannot admit their part and immediately blames them, then that is their problem. If there is self-admission and connecting it to feeling like you are disconnected or don't care, that could be worth investing in to.
Don't get too much advice here. People love to get relationship advice and say what sounds like a dramatic response. It's easy to say, "leave him," but it's hard to stay and work on things. However, if you choose to stay and work on things, then work on things, don't let this moment pass. Hold him accountable, and you hold yourself accountable. You should be allowed to ask questions to learn more about him and what he wants/needs in life. Try to love him again and learn to forgive.
That is key here, if you choose to be with him, you have a lot of work to do, not to get bitter, which you do this by forgiving. You will have to make peace with the former, and if you cannot do that, then I have to say it probably won't work together. You will become bitter, justify your bitterness, and then get angry, resentful, and then be mad at yourself for wasting your life on him.
He put you in a tough spot, but you are here now. Honesty is always the best policy, so get to know what you feel and think so you can present that. What I mention here is to help frame thoughts and ideas going forward and ask questions to help guide you to where you want to go.