Someone who is in an absuive relationship / their partner cheats / has addictions that make life tough.... an affair might seem more understandable as they've already been treated appallingly by their OH / they don't owe them anything / the relationship is effectively over anyway etc.
However, it still isn't the right thing to do. It's possibly more morally justified for the reasons above, but if you want out of your relationship - leave it, don't cheat. If you don't want out of your relationship - cheating won't make it any better so don't do it.
And for the cheater in these situations - if they've been through tough times / abuse, the last thing they need is to jump into another relationship.
So from whichever way you look at it, cheating isn't right. Just perhaps more understandable in some situations. I know of a couple of women who developed relationships with other men when they were in abusive home environments, because they were attracted to 'normal' decent men who treated them kindy. In both cases it gave them the strength to leave their husbands and both, decades on, are happily married to their AP. For them, I'm glad they did it, but it doesn't make it morally right and it doesn't always (mostly?) work out that way.