Smiley, you need to look at this logically:
He spread malicious and horrible gossip about you to your nearest and dearest FOR NO GOOD REASON
He ruined your relationship with your best friend, someone who might perhaps have warned you about this man and his behaviour
He is sneaky and deceitful
He is selfish in his needs, expecting you to have sex even after you've had surgery down there
He set up two accounts on dating websites, one for married people
He lied about the other account
Now as usual you are talking about staying together for the sake of the kids. I hear that all the time on these type of threads. The OP realises that he is a bastard and a dick but in typical helpless fashion she makes excuses for him and says that she has to stay for the sake of the kids.
I hope to God you are not going to do that.
You want to know why he wanted sex when things were going well in your relationship? Because that's exactly what he wants; a nice homelife with an obliging wife and friends who all look up to him whilst he has a sordid affair on the side. His confidence is boosted by the happy patch and he wants more. If he did this whilst you were going through a rough patch, you might be more inclined to keep an eye on him. After all, you already know that he's sneaky and deceitful right?
As for the kids, well what do you think would be more damaging? Having two parents who are unhappy, in a relationship without trust, honesty and respect or two parents who are happily living their own separate lives and who spend quality time with the kids?
Often separated parents do just that, the time they spend with the children is quality time.
But you haven't split up with him yet so there is no point in jumping the gun. You are merely trying to understand his actions and I really think that is a waste of time. You won't ever understand him. You might think you know him, but you obviously don't.
I do fear for your marriage but my worst fear is that he will end up controlling you, he'll put the blame back onto you and make you feel that you drove him to this, that you are at fault, that you are spying or being jealous and you will take all of this onboard. You will beleive his promises and you will take the safer option which is to sweep it under the carpet and hope that your marriage can move on.....until the next time he gets caught out.
I think you are getting some great advice here. I hope it makes a difference.