The primary purpose of the Law is, like a mirror, to teach man the true knowledge of his sin. We see this in the example of the publican.
The publicans were tax-collectors for the Roman imperialists. They were Jews, but were not respected by their people. They were considered traitors and thieves, with some justification.
So the publican did not approach God with pride, demanding what was owed him. On the contrary, he approached the Lord with maximum humility and true repentance. Repentance is essential to receive the forgiveness of sins in Christ. That is why the Law should be preached to unrepentant sinners, but the Gospel to those who are troubled by their sins and terrified of damnation.
The Law demands, threatens and condemns; the Gospel promises, gives and confirms our forgiveness and salvation. God offers forgiveness of sins only in the Good News that we are saved because Christ fulfilled the Law, suffered, died and rose from the dead for us.
So let us draw near to God in humility and repentance, of course, but also in the hope and faith that we are justified through faith, not by works, and that in Christ we are children of God.
David Ernst, By Faith, Not by Works