I know in my own marriage I stayed in it to provide my son with what I thought was a stable background and to give him what I thought was the family life a child should have with two parents. But that isn't always the best way and it took me taking my son to therapy after the divorce to really see it.
The law is an adroit mixture of customs that are beneficial to society and could be followed even if no law existed and others that are of advantage to a ruling minority but harmful to the masses of men and can be enforced on them only by terror.