I believe that there are some cases where it does more harm to stay in the marriage than divorce. This is true for abusive environments. And in such cases, there are just reasons to separate, or so says somewhere in the canon law of the Catholic Church.