In defining what the law is, the purpose of the law is implied. The law was God’s law and a revelation of His will. As F. F. Bruce points out, to keep the law was to do the will of God. No one had greater devotion to the law than Paul. Rather than securing his righteousness before God, Paul’s keeping of the law actually lead him into sin. This is precisely what Luther and Calvin believed the purpose of the law to be: reveal sin to the sinner!
The law places obedience within the context of God’s deliverance at the exodus, an act of God’s grace towards Israel. Deuteronomy repeatedly points out that Israel’s election is not a result of their works but rather God’s unconditional love (7:7-8; 8:14-18; 9:4-5). There are additional examples elsewhere pointing to obedience as a response to God’s grace and not the means of salvation. Deuteronomy offers life for obedience (30:11-20) but also makes clear that the Israelites will not obey and must depend on God’s gracious intervention for deliverance from sin and its consequences (28:15 – 30:10; 31:16-29; 32:1-38). Thielman also points out that Jeremiah and Ezekiel look forward to a time when God will remake the hearts of His people and send his purifying Spirit among them so they will obey. Daniel also holds out hope that God will not deal with His people as they most certainly deserved but will have mercy on his people (9:16-19).
Given the clarity of God’s Word, many first century Jews did not read their Scriptures this way. Many saw Deuteronomy 30:11-20 as simply stating that obeying the law results in life and disobedience results in death, a simple line in the sand where one chooses on which side to stand. Many Jews, though certainly not all, erroneously believed that keeping the law in and of itself made them righteous before God forgetting that the law was given as a way of maintaining their relationship with God after the exodus and not as a means for salvation. Salvation is and always has been by faith. There is not nor has there ever been justification by works of men. This was as equally true in the first century as it is today.
In Galatians 3:10-11, we clearly see that the law demanded perfection and that a curse was attached to failure to keep any part of it. “10 For as many as are of the works of the Law are under a curse; for it is written, “CURSED IS EVERYONE WHO DOES NOT ABIDE BY ALL THINGS WRITTEN IN THE BOOK OF THE LAW, TO PERFORM THEM.” Paul clearly shows his audience that being under the law is a curse. Paul also clearly shows that justification is available through faith. Paul is not condemning the law in Galatians 3 but rather is pointing that it is not possible to perfectly keep the law as OT Scripture commands. Thus the way of the law will always lead to a curse. That is why we have always been justified by faith just as Abraham was over 400 years before the law was given to Moses (Gal. 3:6-9).
The purpose in giving the law is to magnify sin and demonstrate that righteousness through the law was not possible as it is not possible for anyone to keep the law. Salvation is and always has been through faith. Schreiner also points out that the power of God’s grace shines brighter when conquering human sin.
 Bruce, F. F. Paul: Apostle of the Heart Set Free. (Grand Rapids, MI / Cambridge, U.K.: William B. Eerdmans Publishing Company, 1977), 188-189.
 Walvoord, John F., Roy B. Zuck, and Dallas Theological Seminary. The Bible Knowledge Commentary: An Exposition of the Scriptures. (Wheaton, IL: Victor Books, 1983-c1985), 598. Here Paul quotes Deuteronomy 27:26 (NASB) explaining why the law is a curse rather than a means to attain righteousness. All parts of the law must be kept perfectly at all times. This is simply not possible for human beings to accomplish without divine intervention. Paul goes on to quote Habakkuk 2:4 to advance his position that the righteous shall live by faith. See also Schreiner, Thomas R. The Law and Its Fulfillment: A Pauline Theology of Law. (Grand Rapids: Baker Books, 1993), 46-48.