I’m grateful to know a lot of smart, capable women. Sadly, many of these smart, capable women have committed themselves to guys who are clueless, emotionally unavailable, or just plain jerks. How does this happen so often?

Of course, hetero ladies aren’t the only ones who deal with this phenomenon—this problem runs across all lines of gender and sexuality. No matter who you are or who you’re attracted to, it’s more than plausible that you’ve gotten together with someone who’s straight-up bad for you (and probably on more than one occasion).

Why do we do this? How do lovely people wind up with such unlovely mates? I spoke with a range of psychologists and relationship experts to find out the mystery behind why we so often end up with bad partners and why it’s so hard to leave—even when we know it’s not working.

Everything’s scary

One of the simplest reasons people stay with bad partners is this: fear. Sometimes it’s easy to think, If this doesn’t work out, maybe nothing will. So they stay with a less-than-ideal partner to avoid the possibility of loneliness.

A study from the University of Toronto found that participants with a stronger fear of being alone were more likely to settle for a crappy relationship. And although we stereotypically picture guys as commitment-phobic or marriage-averse, it turns out they’re just as scared of a never-ending single life—this study showed that the fear of being alone drove both men and women equally.

The idea of breaking up with a bad mate doesn’t just bring up the fear of being alone: You have to deal with the potentially horrible, frightening prospect of dating again. “For some, dating can even be depressing,” says licensed mental health counselor Shani Graves. “We’d rather silently suffer in a relationship that gives a sense of companionship than start all over again.”

No matter who you are, dating is hard. You have to experience weird small talk; potentially rude, unpleasant, or even creepy people; and that one guy who will go out of his way to call you ugly and awkward when you reject him (which, yeah—that’s a personal, true-life tale). So when you combine the mess of dating and the scariness of being alone, you get a whole ton of fear. And that fear keeps couples together that should have parted long ago.

It’s easy

It’s easy to see a relationship from the outside and say, “Just leave her! She’s been trying to make it as an amateur DJ for ten years! For the love of God, just go!”

But think of it from the other side: In a long-term relationship, a breakup is tough, and not just emotionally. “There are many everyday reasons for staying—convenience, routine, stability, habit, etc,” says clinical psychologist David Woodsfellow, Ph.D. “All of these are real—and important. These should not be underestimated or downplayed.”

There’s a lot of hard work that goes into a breakup. You probably have to move out, separate your things, and become completely financially independent again. Maybe your partner used to always handle the taxes. Well, no more. Time to get your own CPA and slog through a pile of 1099s!

It’s even more complicated if you have pets. Who gets the dog? Will Puppy McRuffles have to stay weekends at your ex’s house or can you just keep him? Then there’s friends. Can you still hang out with “their” friends? Will they cut you out of their life because of the breakup? Will it be weird if your old friends still want to keep in contact with him?

Oh, and family. You probably met their family. In fact, they might be just as (maybe more) important to you as your own blood relatives. After a breakup though, that newfound family probably won’t be around to support you.

And good God, kids. If you have kids, it’s a whole new world of complication.

So you already have to split your life in two and you have the added stress of explaining your choice to everyone around you. “There is the perception that you have to justify your reasons for ending the relationship to others—friends, family—in a way that makes sense to them,” says Lesli Doares, relationship coach, author, and radio host of Happily Ever After is Just the Beginning. She feels that couples sometimes stay together partially because they don’t want to explain why they’d rather be apart.

Doares goes on to say that the pressure from friends, family, and society to stay together is hard to overcome. And when you add in all the physical and emotional separation that occurs with every breakup, a lot of people don’t want to go through that pain. So they stay together with someone they know isn’t right simply because it’s easier.

Throwing in good time after bad

“The No. 1 reason I see women stay in terrible relationships is because of return on investment—ROI,” says relationship expert and life coach Kali Rogers. We don’t often think of relationships in Shark Tank terms, but the idea of getting a good return on our investment of time is what keeps lots of relationships together for much too long. “Once we’ve put so much time, effort, love, and attention into anything—we want to see the results we believe we are entitled to,” Roger says. “It’s much harder to cut your losses and walk away than it is to stay and put in one more hand.”

A study published in Current Psychology agrees that people are likely to keep throwing in good time after bad; participants were asked to imagine a bad relationship and decide whether they should stay or go. The longer the relationship, the more likely the participants would opt to stay.

Rogers says the same idea that keeps couples together is what keep gamblers at the poker table. Some think, I’ve lost a ton of money, but this next hand just might make everything right again! In relationships, we think, Yeah, those last five years were garbage, but maybe this year I can finally make it right!

It’s hard to give up when you’ve spent years of your life on another person. And for some, it’s just too hard to let that all go and start again from scratch.

The boiling frog theory

Some relationships are a bit like the hypothetical frog in a pot. If the frog jumps into boiling water, it’ll jump right out. But if the frog is sitting in the water and it slowly comes to a boil, the frog will sit there and happily get boiled alive while thinking, Yeah, things are definitely staying the same in here.

I may have added a bit of color to the story (also, it’s not true, but does make for a nice little parable). But it’s easy for us non-frogs to behave this way. “When entrenched, we’re so involved fighting fire every day, it’s hard to realize you’re in hell,” says clinical psychologist and executive coach Perpetua Neo, DClinPsy, MPhil. “This is akin to the frog in boiling water concept. As the heat gets turned up, you get used to having your boundaries trampled upon and your standards eroded as your new normal.”

This is especially true if low self-esteem is one of the things keeping a person in a poor relationship. “We don’t believe we deserve better,” says Neo. “Relationships can shine a light on our deepest insecurities, and most of us, to some extent, feel we aren’t good enough and are plagued by that.”

That deep-seated self-hatred can be made worse by a toxic relationship. An abusive partner can make you feel insignificant, stupid, and unloveable. Then, they’ll turn around and claim that they’re the only one who could possibly love you as you are. This type of gaslighting and emotional manipulation is common—and it works. When you already feel like a worthless person, it’s easier to stay with someone who reminds you of how worthless you are, according to Neo.

This erosion of self-esteem and happiness doesn’t happen overnight, of course. It’s slow… slow enough for you to get used to bad behavior and unhappiness. So slow that you might think, Yeah, things are definitely staying the same here, as the water starts to boil.

Try to change the past — by repeating it

Our past has a huge impact on our present relationships. So, if there’s unresolved trauma from years ago, it’s likely that trauma’s going to pop up again in the present day.

Sometimes, people get in bad relationships because they don’t know any better. Bessel van der Kolk, M.D., has theorized that experiencing violence as children directly correlates to experiencing violence in marriage.

“People who are exposed early to violence or neglect come to expect it as a way of life,” he writes. This is true for children who witness marital violence or kids that were abused themselves. In both scenarios, love and violence are intertwined, and totally outside of the child’s control. As an adult, that person still sees a connection between love and violence, and can feel completely helpless as to how to stop it.

This is true for violent and non-violent relationships. If your parents fought all the time and had a horrible marriage, you are more likely to have couple troubles yourself. Woodsfellow says that people often stay in relationships to replay a significant moment from childhood. This kind of replaying is our weird way of trying to work through trauma from the past. Sometimes, it helps us come to terms with bad things from childhood. Other times, we just repeat the same mistakes, according to Woodsfellow.

Sometimes, we repeat trauma in an attempt to “fix it.” According to relationship therapist Rhonda Milrad, LCSW, “You seek out someone who treats you badly with the unconscious desire to win them over and get them to change their behavior toward you. You are trying to affect in your current relationship what did not not happen in your childhood.” So if you can fix your boyfriend and make him love you, maybe you can fix your dad and make him love you, too, this line of thinking goes.

“The problem is that you cannot change another person, only yourself,” Rogers says. Often, the more you try to change your partner, the more you get back the same obnoxious or abusive behavior that scarred you in the first place.

No matter how hard you may try, you can’t make a person change. Sure, you might be able to train someone to quit leaving their socks all over the living room floor, but you can’t “fix” them. But there’s still hope, says Woodsfellow. “Of course, you can’t force someone else to change, but I think it’s sometimes a good thing to ask someone to change something,” he says. “I think that kind of mutual influence is part of a healthy marriage.” But if you’re with someone who doesn’t want to work on themselves, change, or grow, then that faraway hope that you could be the one to “save” someone can be so captivating, it makes it even harder to let that bad partner go.

That’s all depressing — are we doomed to stay in bad relationships?

Finally, some good news: You absolutely can leave a bad relationship. It just takes a lot of courage and support. Milrad stresses the importance of a support system, friends, and family, as a way to get out of a bad situation. If you have people to help you through the tough times, it will be so much easier to leave.

Also, you have to take a look at yourself: Are you attracting the same type of bad person over and over? Are you using relationships to replay past trauma? Are you a “fixer?” Rogers says you need “an awareness of what issue you are trying to work through to stop repeating it in a similar pattern with subsequent relationships.” Thankfully, with help from friends and possibly some therapy, you can isolate those scars of the past and ensure you don’t keep repeating them in your future.

And it’s a good idea to examine your own issues and hang-ups that may be contributing to your relationship being less-than-optimal. “In many long-term relationships, both parties contribute to the difficulties,” Woodsfellow says. “Yes, sometimes you’re innocent and your partner is to blame. But while that’s sometimes true, it’s not always true. Sometimes, it’s worth trying to change a problem and change your own reactions before concluding that things are hopeless.”

Overall, just remember this: You deserve happiness. You deserve love. And if you aren’t getting that from your current relationship, you deserve to leave.