Sometimes ending the relationship will harm third parties, but the core relationship is harmful to one or both of the people in it. In a case like that cheating may be the least bad option.
Primarily children. Consider a situation where one member of a married couple is unwilling or unable to engage in sexual contact but is otherwise a good partner and coparent. Divorce is traumatic for children and has a significant negative economic impact, life with single parents is also difficult. So the parent who still wants sex seeks it elsewhere. They are fulfilling an important aspect of their life, and preserving a healthy home life for their children and partner.
Remember the premise, cheating is lying about the situation, and acting on those needs without consent.
There is no world where that is healthier than whatever mutual agreement the couple could end up in, after honestly sharing their situation.
If the care for the needs of the child is real and actually shared between the parents, anything ranging from a sexually open marriage, to a divorce with uninterrupted coparenting, is leagues better than pretending you want to be there while actually both having a bad time around your child's other parent, and constantly lying.
??? That's not a recipe for cheating, that's a recipe to either open the relationship or to get law enforcement to help you escape abuse, depending on the situation with your partner. In no way will sleeping with someone else behind your partner's back and risk them finding out about it help ANYONE involved