Hi, I'd like to help you with your question.
He goes back to her because he can and she will accept him. Some men do not have a problem with cheating and feel that ex's are safe bets. They can be with them without the commitment and problems they had before in the relationship. Now it's sex and some contact without any relationship issues. This means he probably does not want to go back with her. If he did, then he would be dealing with the same issues he did before he left. The relationship would not last unless they worked their problems through. And he probably would not stop cheating either.
Your boyfriend wants to have his cake and eat it too. He cares only about his needs being met. However, once you and his ex start to communication and mess things up for him, he gets upset. This is why he treated you badly.
Your boyfriend may like you but he is thinking of himself at this point. He is not putting you first or his ex. He is putting himself first. So as long as he thinks of himself, he will most likely not be faithful to anyone.
I hope this helps you,Kate