From The God Who Justifies.
“In the Old Testament, the term “to justify” is often used in the judicial sense, that is, in the context of the court of law. Given the parallels that exist between Paul’s use of the same words to describe justification by faith in the very contexts that define the doctrine we are examining, we should look carefully at some of the key passages. We’ll examine both the NET and the NASB.
Exodus 23: 7
Keep your distance from a false charge— do not kill the innocent and the righteous , for I do not justify the wicked. (NET)
Keep far from a false charge, and do not kill the innocent or the righteous, for I will not acquit the guilty. (NASB)
Clearly the context of Exodus 23 is legal. The preceding verses include instructions on lawsuits and general exhortations to justice and honesty. In this one verse we have judicial terms such as “false charge,” “acquit,” and “guilty.” We also see the key word used twice— once as a substantive (“righteous” or “just” in the phrase “do not kill the innocent and the righteous”)  and once as a verb (“ justify” or “acquit” in the phrase “justify the wicked”). 
In the first phrase God’s law says that the innocent or the righteous are not to be killed. Obviously, this does not mean “those who are sinlessly perfect” but rather those who are innocent or righteous in the eyes of the law. This is a legal, not a moral, description.
But even more important is the second phrase, “I do not justify the wicked. Some might think this is contradictory to Paul’s description of God as the one who does justify the ungodly (Romans 4: 5), yet such would involve ignoring the context of the two statements. God, in His justice, does not “justify the wicked.” He justifies the ungodly in His mercy and grace, and only on the basis of the work of Christ that satisfies the demands of His absolute holiness and justice. In this passage, God is stating simple justice: He will not justify the wicked.
But what does this mean? It’s obvious that God is not saying He does not internally change the nature of wicked men into that which is objectively pleasing to Him— this He does. The context in this passage is forensic, that is, legal. God is saying He will not declare a wicked man to be righteous , for such would be a perversion of justice. God does not do this in justification by faith, either: Christ’s substitutionary death is the sole basis of his declaration. This use of the verb “justify” is clearly a forensic, legal declaration regarding an individual’s standing before God and His law.
5 In Hebrew, צַרּיק, and very importantly in the Greek translation of the Old Testament (which was the Bible of the New Testament church), known as the Septuagint (often abbreviated LXX), δίκαὶον.
6 אַצְרּיק, and in the LXX, δικαιώσεις.
White, James R. (2007-05-01). God Who Justifies, The (pp. 61-62, 76). Baker Publishing Group. Kindle Edition.