Your marital relationship obviously plays a huge role in your child custody case in numerous ways.
However, it's important to remember that your perspective is not the same as the court's. They are not interested in the same aspects of your relationship that matter to you. In this sense, your marital relationship loses importance and the relationships each of you have with the kids become the focal point.
For example, one person said that her ex had cheated on her. In her mind, that meant he'd abandoned the kids at the same time. She wanted to know if the courts looked at it the same way, perhaps giving her custody because her husband was the one who "left" the family.
One expert pointed our that they would care far more about the relationship that father had with his kids than the relationship he had with his former wife. He was part of the kids' lives before the split. That didn't have to change after it, even if the relationship between the former husband and wife had changed dramatically.
In short, just because the man was not a good husband and violated the commitment of the marriage in no way means that he absolutely won't be a good father. He still likely has a right to see his kids and be part of their lives. The court isn't worried that the former spouse won't like that because there is now baggage between the two adults.
If you're heading to court, it's crucial to understand how the authorities view your case and what legal options and rights you have.
Source: The Spruce, "Child Custody Laws, Resources and FAQ's," Jennifer Wolf, accessed Oct. 18, 2017