Morality is maintained on a community through the action of every individual. That is, when someone breaks a rule, the rest of the people in the community will reprehend him. This punishment might come in many forms and intensities, from verbal reprehension to physical attacks, sometimes including death. But the mere display of disapproval is always present, and one of the post powerful punishments when all the community does it at the same time.
As it is a play between individuals, it is possible to try to keep a misdeed secret. When that happens and someone else is caught committing the same crime, the first person will naturally have a degree of empathy towards the second. But if he shows it, he will raise suspicion towards himself. So he must seek to be more proactive in punishing the person, and expressing his disapproval. He might not want to lead the prosecution, but sometimes he might even be forced in such a position.
That way, the more people go against the moral code in secrecy, the more energy will be turned into punishing anyone caught doing so. That, besides enhancing the “hypocrisy level” of the society, also makes the moral code much more strong, for a large amount of energy is being applied in it, through the punishments and judging.
That is an false paradox: that a moral code that no one can follow will become stronger with the passing time.
Some conditions must be met, obviously, such as the possibility of sin in secret and very unpleasant forms of punishment, but in general the process should be fairly sustainable in the long run, albeit creating a very vicious and explosive society. It would develop a kind of veiled violence which should be very powerful. Given such conditions, many would be trying to use this violence to achieve personal goals, and that would cause a turbulent (but probably thriving) history.
It should not be necessary to point that many examples are easily found throughout history, and that catholicism and it’s repression of sexuality are specially appropriate.