What an uncomfortable situation! I think what I probably would have done, and I feel like I have done this although the situation wasn't so extreme, is to make a joke at some point that kind of highlights the inappropriateness of what's being discussed--even if it's just saying, "AWKWARD!" or "Wow, TMI!" Then I usually get up and leave for another room or something.
I usually let others fend for themselves, but if there's someone else looking uncomfortable or not participating, I think it would be perfectly fine to draw them into another room or another conversation. Like, "Hey, Joe, did you make the pumpkin pie? I'm going to go have another piece, want to come with and tell me how it's made?" It's not super-smooth, but I think in a situation like this, smoothness is not really what you're going for, you know? A little nudge that people are talking about something they shouldn't and that you don't like it is, I think, appropriate.
And, I also want to second the idea that the couple do need to stop yapping about their marital problems to these relatives. Unless it was something like, they actually said very innocuous things and the relatives were picking them apart for hidden meanings. If I felt close-ish to the couple being discussed, I think I would drop them a line about it. "Hey, this is super-awkward for me, but I thought you would want to know that a bunch of [unnamed] family members were discussing your marriage the other day. If I knew people were saying those things about MY marriage, I would be really uncomfortable and would want to know about it, so I wanted to tell you. That's all I'm going to say about it, though." Maybe an email.