In the distant past, there were no prisons, and individuals who repeatedly violated the norms of the society were banished, often with the understanding that they would be killed on sight. This would push the problem off onto the future or onto other groups. Or, sometimes, the group would decide that the individual had so transgressed that they would kill them outright for their actions.Execution has nothing to do with revenge. Revenge would be allowing the families of the murder victim to kill the murderer with their own hands.
but, surprising to us modern folks, in many traditional indigenous cultures, the taking of a life within the extended group, and sometimes from other groups, was a matter settled with payment by the killer (or his/her family or group) to the victim's family or group. Of course, if the person or their family/group could not or would not pay, well, that could be resolved through the methods mentioned above...
To me, those methods are 'rational' given the circumstances of the times. Sometimes people need killed. But to me, it should always, always, always be the absolute last resort, and with the exception of defense of self or group members, should always be an agreement of all of the society.