People with low self-esteem will often find partners and friends who support this belief by being mean or treating them badly. For example, a woman may hook up with a man who is alcoholic, repeatedly unfaithful, violent or just puts her down all the time.
If you see this happening to other people, it's easy to give good advice. When it's happening in your own life, it's harder to do what you know is right, but the bottom line is that if you want to be happy, you have to stop accepting being treated this way.
The first step is to make it clear that the bad behavior is not okay any more. If that doesn't work, you may decide to get out of the situation.