"But before faith came, we were kept under the law, shut up unto the faith which should afterwards be revealed. Wherefore the law was our schoolmaster to bring us unto Christ, that we might be justified by faith. But after that faith is come, we are no longer under a schoolmaster."
The key to this text is in the first four words: "But before faith came." Paul is talking about his condition of condemnation before he exercised faith in Christ. Being "under the law" is defined in Romans 3:19 as being "guilty before God" and under the sentence of death. During those years of sin Paul was "kept under the law"--held in the prison house of disobedience. In Romans 7:23, he spoke of that experience of condemnation as "bringing me into captivity to the law of sin."
But even when Paul was outside of Christ, without faith, the law was operating on his conscience, magnifying his misery and condemnation (Romans 7:13) and leading him step by step, like a schoolmaster, to the Saviour. After being directed to Christ by the law, Paul says we are "justified by faith." This is what the law could not do. It could not justify; it could only condemn. Christ freely forgives and delivers.
The last point Paul makes is that we are no longer under the law, but under grace. After bringing us to Christ, the law no longer condemns because we, as Christians, do not break it. It will still be there to shepherd us back to Christ if we depart from His grace, but it no longer condemns us as transgressors so long as we abide in Him.