Keep quiet. No-on should read anyone else's messages, even by accident, as it causes trouble- my dad has a saying that those who listen at doors, never hear anything good- not quite the same, but it still applies!
I know this was an accident and my point above is not logical, but the real point is that the "friend" who saw the text should have kept it to him/herself- they have now passed the problem on to you, in a way. I'd tell the friend that you wish he hadn't told you- and that you are keeping out of it- sounds like you are all over-involved in a marital upset and that's not right. leave them to it.
I can relate to something like that- but not quite the same. Many years ago, I was giving my best friend's bloke a lift home- been living together for many years ( they did eventually split up!). he made a very forceful pass at me, once I had dropped her off at her house. No uncertain terms- what he wanted to do. I was horrified, but laughed it off and told him to get out- or I'd tell her.
I have never told her to this day- I wanted to, as I thought if he was like that with me, 5 minutes after she had left- what would he be like in another situation?!I wanted to tell her to protect her, but at the same time, I didn't want it misinterpreted- such as me encouraging him - which i hadn't.
it's not quite the same- but is DOES involve withholding something from someone that could be in their best interests, but which you feel would upset them too much. Their eventual split was nothing to do with unfaithfulness- she left him for other reasons.
Keep out of it- it might be tempting to "play god" but leave well alone.