It Shows Just How Good We Have To Be
The law was given so that man could see the condition of his relationship with God. To be acceptable to Him, we must be perfect, holy and righteous. The law shows just how imperfect, unholy and unrighteous we really are.
All of us have become like one who is unclean, and all our righteous acts are like filthy rags; we all shrivel up like a leaf, and like the wind our sins sweep us away. (Isaiah 64:6)
Contrary to what most of us have heard in church for years, attempting to follow the law is not intended to make us closer to Him. Rather, it's to show us how far away we are from God. That's why there were all those rules and rituals for offerings and sacrifices in which blood had to be shed. They demonstrated the severity of the consequences of our sins.
It Only Condemns and Nothing More
The law was designed to condemn us by pointing out our faults, our guilt, our sins. It is supposed to stop us from bragging about how good we are and to show us how desperately we need God's mercy. The law's goal is to break through our stubborn pride and lead us to Jesus Christ for salvation.
Now we know that whatever the law says, it says to those who are under the law, so that every mouth may be silenced and the whole world held accountable to God. Therefore no one will be declared righteous in his sight by observing the law; rather, through the law we become conscious of sin. (Romans 3:19-20)
Before this faith came, we were held prisoners by the law, locked up until faith should be revealed. So the law was put in charge to lead us to Christ that we might be justified by faith. Now that faith has come, we are no longer under the supervision of the law. (Galatians 3:23-25)
It Was a Covenant Given to the Israelites
Actually, the law that we usually refer to was only given to the Israelites at Mt. Sinai in the form of the Ten Commandments. More laws and statutes and regulations were added to govern their conduct, worship, and even their diet. All the laws had the one very special purpose: It was to show God's greatness to the nations around Israel by what He required of his people.
What other nation is so great as to have their gods near them the way the LORD our God is near us whenever we pray to him? And what other nation is so great as to have such righteous decrees and laws as this body of laws I am setting before you today? (Deuteronomy 4:7-8)
But the Gentiles Have a Similar Law
Although, it was specifically given to the Israelites, we Gentiles have our own version of the law written on our hearts. That's so that everyone can recognize their spiritual condition and their need for God's gift through His Son.
Indeed, when Gentiles, who do not have the law, do by nature things required by the law, they are a law for themselves, even though they do not have the law, since they show that the requirements of the law are written on their hearts, their consciences also bearing witness, and their thoughts now accusing, now even defending them. (Romans 2:14-15)
We all --both Jew and Gentile alike-- know what it is that God desires for us. He wants us to have eternal life with Him. And to do that we have to be perfectly righteous and completely sinless. The law leads us to Jesus Christ who is the only One who can make this become a reality.