As with all forms of genealogy, the exact history of such things that require guesses is just that – guesses. Such is true of the history behind the word “evil”. And if this is true of the meanings of words, what of the intention of the punishment for such wrong deeds? One could even guess that what we label a sin today, was once considered sacred. What we consider immoral is, in fact, natural. An example of converting the sacred to be something evil is explained in the book The Da Vinci Code: "A newly emerging power will take over the existing symbols and degrade them over time in an attempt to erase their meaning.... Poseidon's trident became the devil's pitchfork, the wise crone's pointed hat became the symbol of a witch, and Venus's pentacle became a sign of the devil...". How could we not even consider that our current "morals" are distortions of previous "morals"? This would contribute to religious diversity because the old moral code would not become entirely extinct, the new moral code is a twisted version of the old moral code, and other cultures could potentially borrow from both.
As part of enforcing a new moral code, those in charge would need to offer some sort of enticement. We can see within religious diversity many different forms of reward and punishment. But, as Nietzsche points out, the same applies to the genealogy of the act of justice, as applies to the meaning of the word justice. “Throughout the greater part of human history punishment was not imposed because one held the wrong doer responsible for his deed, thus not on the presupposition that only the guilty one should be punished ...”. Even today, not all punishment is given out as a result of wrong doing. Punishment is also part of determent. At the extreme, determent could even be mind control. We smack a child's hand when it reaches for the hot stove top, a form of determent, to put in the child's mind that they should not do that. We discipline a dog who pees on the carpet so they won't want to pee on the carpet again. A priest will tell us that greed is evil and separates us from our god, so that we won't want to be greedy. And so on.
But punishment is not enough to change the moral code. Mankind also wants an ultimate reward for their "good" deeds. Then, we see in religion, payments for guilt. Payments are meant to represent repentance, so that an ultimate payment not be owed after our death. Those responsible for creating the new context of guilt, also provided a way to discard of the guilt. So what sorts of payments are made to get rid of guilt? Sacrifices, alms, tithe, etc. And who do those payments go to but the same ones who created the payment to escape the guilt that they also created.
Someone always benefits from the code of morals.
Look up the etymology of other common words.