Love yourself
People having issues with their self-esteem usually end up with partners who treat them badly because that is what they think they deserve.
Instead of going back in time and analyzing your previous relationships to find out what went wrong, look inward and find more about yourself.
Psychologists advise that you take a break from relationships and instead rebuild a loving relationship with yourself.
You could consult a therapist for help, or you could read a book on the subject matter.