You're right that kids will see when there are problems in a marriage. A child has to be either very, very young (think preschooler and younger) or significantly mentally disabled to not notice such things. People who think their kids have no clue are selling their kids short - the kids absolutely know.
As for your own situation, you are making it harder for this guy to figure out what to do. Sexting gives him a thrill so he puts off figuring out what to do. So does confiding in you. So stop.
I know you'll say, you've known him for so long, it's not like that, yadda yadda yadda we have seen all of it before here.
Admit it: the sexting is an ego rush for both of you. And by giving him this kind of rush, he continually fails to face reality.
If you care about him as a human being at all, you'll cut this **** out and look for companionship with someone who knows WTF they want out of life. If he leaves his wife (and chances are extremely good that he won't
), then that's one thing. But maintaining a limbo existence isn't just unfair to his wife. It's also unfair to his kids, him, and even you.