There are a few reasons why we might stay with someone who does nothing but drag us down and hurt us. The underlying reson is often to do with validation and self esteem. When you get with someone you get all kinds of good feelings. You get acceptance of who you are, you get a confidence boost, you feel happy, you feel worthy. You start to rely on all of these things because you invest in the person that you are with. You put your efforts into making the relationship work. It matters to you.
If that person starts to stray it shakes the very foundations of your self belief. If it is early enough into the proceedings then you might have the strength to walk away. Maybe you even did so in the beginning. However, that need for validation from him is hugely powerful. All of the acceptance and the reassurance that you got from his attention is suddenly taken away and you find yourself struggling for self worth. Perhaps he manages to convince you that he will change and you decide to give him a chance. Accepting that he made a mistake is so much easier than taking all of the pain and emptiness. So you reinvest and you try to make it work. The longer it goes on the more you get hooked. The more he rejects you through his affairs the more you crave the feelings that you rely on him for. In the end you base your entire sense of self worth on this one person, despite knowing that he is not even worthy of YOU.
It's a vicious circle and the longer it goes on the worse it gets. When you finally lose him you are left with no love for yourself. You feel stupid, you feel small, you feel unworthy and you feel that only he can bring back all of the things that you have lost.
Of course, this is all illusion. You never needed him to make you worth something, you have ALWAYS been worth something. It will take time for you to be able to see that. It will take time because you have to build up that realisation that you can be good and strong and powerful without his affirmations. Your worth is not measured by the affections of one person. Nobody's worth is measure by the affections of ANY one person. This man was fundamentally flawed. He was always the weak one, you just couldn't see it.
Once you have managed to grieve, which will undoubtedly take some time, you will start to make a life that is focused on yourself and not on yourself as purely an extension of some guy.