Deuteronomy 19:20 And those which remain shall hear, and fear, and commit no more any such evil among you.
The purpose of carrying out justice and punishing evildoers is that it be a deterrent to others, “those which remain,” that they might hear about it, be afraid of it, and so be prevented from doing the evil. Human government is established by God to uphold the Rule of Law and a fair Justice System. The “eye for an eye” thing in v. 21 is a principle for government to follow: to enforce a just penalty and not be excessive. It is not up to individuals to seek vengeance or to get even. “Vengeance is Mine,” not yours.
Six cities of refuge were set up to prevent the avenger of blood from taking the law into his own hands. Allow the judges to exact the death penalty for premeditated murder on the basis of two or three witnesses. This law combines justice and mercy. In addition, if a witness lies (commits perjury) he shall suffer the penalty.
A governmental system of laws is necessary for sinners to live peaceably in a sinful world. Without restraints, sinners would destroy themselves. Deterrents are necessary to prevent sinners from gross evil.
We must also admit that while good Christians do good things because “the love of Christ compels us,” we also need a dose of the fear of God. There are bad things we don’t do for fear of God’s displeasure and of grieving the Spirit. Proper fear and love of God deters sin and motivates righteousness. Our response to the Law is to “fear and love God so that….” A humble spirit repents and believes the gospel.