Understanding the truth of the Law produces the fear of the Lord. See Rom. 2:17–24 for how Paul used the moral Law to bring the knowledge of sin. Seeing sin in its true light makes us rightly fear God, which causes us to depart from sin.
“When man, conscious of his failure to keep God’s command, is constantly urged by the Law to make payment of his debt and confronted with nothing but the terrible wrath of God and eternal condemnation, he cannot but sink into despair over his sins. Such is the inevitable consequence where the Law alone is taught with a view to attaining heaven thereby.” Martin Luther
2 Chronicles 17:9 And they taught in Judah, and had the book of the law of the Lord with them, and went about throughout all the cities of Judah, and taught the people.