It is thought of as harsh and vengeful, but it’s actually defining limits - no more than —
I tend to concur- punishment under the Law was meted out most typically congruent with the crime.
Some crimes(sins), however were dealt with quite harshly by today’s standards. Adultery, witchcraft, etc.
I think they were the signs of apostasy, to be driven out so that Israel was pure in the eyes of the LORD.
Today we are under a new covenant and may rely on God to exact justice.