Not to mention, it was leaked to the media, everyone already knows about it. How exactly could that be used to blackmail someone if the entire world already knows about it?
I suppose you think Clinton should have resigned (instead of lying about the affair, which made everything worse)?
Now, maybe you think those rules are stupid. Frankly, I think some of them don't make a lot of sense (or at least fail a cost/benefit analysis), but I don't make the rules. Petreus agreed to follow those rules. If he didn't like them, he could have refused the job. Or he could have worked to change them. But he didn't. So he has to live by them. And he failed to do that.
Also, the people involved have probably learned from painful experience that traditional institutional rules are usually better guides than they sometimes appear to be at the moment of decision.
If anything I would guess that he was fired for allowing his secret to leak (which means incompetency).
Realistically though, all that scandal is just a cover for real reason why Petraeus was fired - probably something like policy disagreement with superiors.