Galatians 3:10-11 (NIV)
All who rely on observing the law are under a curse, for it is written: "Cursed is everyone who does not continue to do everything written in the Book of the Law." Clearly no one is justified before God by the law, because, "The righteous will live by faith."
The book of Galatians is like a little book of Romans. Packed in it are fundamental doctrines of the faith. Paul, the consummate theologian, is always quoting the Old Testament to prove the truths revealed in the New Testament regarding salvation by grace. Here he makes a clear and convincing argument that the Law can only condemn us. None of us can claim to have kept all the ten commandments. Furthermore, based on Jesus' teaching that the thought is equivalent to the deed, it can be easily demonstrated that in fact we have broken every one of them. That makes us guilty, or cursed as Paul puts it.
Then comes a clue. Paul, quotes again from Habakkuk that "the just shall live by faith." So then, some can be righteous? But it is by faith, not by works. Faith in what? Paul concludes this argument with another Old testament scripture pointing to a New Testament truth.
Galatians 3:13 (NIV)
Christ redeemed us from the curse of the law by becoming a curse for us, for it is written: "Cursed is everyone who is hung on a tree."
The tree is a clear allusion to the cross of Christ. Jesus was a substitute for us. He, being perfect, would not need to suffer a curse for his own inability to keep the law. Thus he is able to take upon himself the curse of the law on our behalf. God could just let us off the hook, but that wouldn't be justice. He could destroy us all, but that wouldn't be love. This way, the only way, He is both just and loving.