Unfortunately, this is a question I get asked a lot. Many parents stay in relationships, maintaining toxic feeling of sadness or anger towards their partner, because they believe that an intact family is best for their kids.
My answer is always the same. Obviously, an intact, happy and stable family (in whatever form that entails) is the best situation for children. But when that isn’t possible, it is sometimes best for parents to separate, as 2 happy parents parenting as individuals, may end up being better for a child than 2 unhappy parents trying to coparent together. This article explains more https://www.psychologytoday.com/blog/when-kids-call-the-shots/201703/4-reasons-why-bad-marriages-are-worse-kids-divorce