Here is how Dr. Luther puts it in his 1535 Commentary on Galatians
"The Law has a twofold purpose. One purpose is civil. God has ordained civil laws to punish crime. Every law is given to restrain sin. Does it not then make men righteous? No. In refraining from murder, adultery, theft, or other sins, I do so under compulsion because I fear the jail, the noose, the electric chair. These restrain me as iron bars restrain a lion and a bear. Otherwise they would tear everything to pieces. Such forceful restraint cannot be regarded as righteousness, rather as an indication of unrighteousness. As a wild beast is tied to keep it from running amuck, so the Law bridles mad and furious man to keep him from running wild. The need for restraint shows plainly enough that those who need the Law are not righteous, but wicked men who are fit to be tied. No, the Law does not justify.
The first purpose of the Law, accordingly, is to restrain the wicked. The devil gets people into all kinds of scrapes. Therefore God instituted governments, parents, laws, restrictions, and civil ordinances. At least they help to tie the devil's hands so that he does not rage up and down the earth. This civil restraint by the Law is intended by God for the preservation of all things, particularly for the good of the Gospel that it should not be hindered too much by the tumult of the wicked. But Paul is not now treating of this civil use and function of the Law.
The second purpose of the Law is spiritual and divine. Paul describes this spiritual purpose of the Law in the words, 'Because of transgression,', to reveal to a person his sin, blindness, misery, his ignorance, hatred, and contempt of God, his death, hell, and condemnation.
This is the principle purpose of the Law and its most valuable contribution. As long as a person is not a murderer, adulterer, thief, he would swear that he is righteous. How is God going to humble such a person except by the Law? The Law is the hammer of death, the thunder of hell, and the lightning of God's wrath to bring down the proud and shameless hypocrites. When the Law was instituted on Mount Sinai it was accompanied by lightning, by storms, by the sound of trumpets, to tear to pieces that monster called self-righteousness. As long as a person thinks he is right he is going to be incomprehensibly proud and presumptuous. He is going to hate God, despise His grace and mercy, and ignore the promises in Christ. The Gospel of the free forgiveness of sins through Christ will never appeal to the self-righteous.
The monster of self-righteousness, this stiff-necked beast, needs a big axe. And that is what the Law is, a big axe. Accordingly, the proper use and function of the Law is to threaten until the conscience is scared stiff.
The awful spectacle at Mount Sinai portrayed the proper use of the Law. When the children of Israel came out of Egypt a feeling of singular holiness possessed them. They boasted: 'We are the people of God. All that the Lord hath spoken we will do.' This feeling of holiness was heightened when Moses ordered them to wash their clothes, to refrain from their wives, and to prepare themselves all around. The third day came and Moses led the people out of their tents to the foot of the mountain into the presence of the Lord. What happened? When the children of Israel saw the whole mountain burning and smoking, the black clouds rent by fierce lightning flashing up and down in the inky darkness, when they heard the sound of the trumpet blowing louder and longer, shattered by the roll of thunder, they were so frightened that they begged Moses 'Speak thou with us, and we will hear; but let not God speak with us, lest we die.' I ask you, what good did their scrubbing, their snow-white clothes, and their continence do them? No good at all. Not a single one could stand in the presence of the glorious Lord. Stricken by the terror of God, they fled back into their tents, as if the devil were after them." - Mart Luther's Commentary on St. Paul's Epistle to the Galatians (Galatians 3:19)
-CryptoLutheran