Paul isn't saying in this verse that the law of Moses will justify law keepers, but that merely being under and hearing the law is not enough to justify a person. The person must actually perform the law to be just. You have to consider the previous verse to get the context
For as many as have sinned without law will also perish without law, and as many as have sinned under the law will be judged by the law. Romans 2:12
In other words, those who live under the law of Moses are required to perfectly keep the law. This is impossible, of course, as Paul makes clear elsewhere. Consequently, all who are under the law without faith in Christ will be judged by the law.
He's simply drawing a comparison between those who lived under law (Jews), but didn't do the righteousness required by the law, and those who did not live under the law (gentiles), but did the righteousness required by the law (i.e. love of GOD and mankind).