Romans 9:30-31 talk about the difference between seeking a relationship with God (and obtaining righteousness) through the two main biblical covenants (testaments).
The Old Covenenat was a works oriented covenant of attempting to live by the Commandments and the Law of Moses in order to earn your way into heaven. That covenant was never intended by God to be the way the humans could attain a relationship with Him. That covenant was designed by God to fade away and to be replaced by a superior and enduring covenant, the New Covenent of grace and faith.
The New Covenant is a grace covenant where a person receives righteousness by being declared righteous by God through faith.
As Genesis 15:6 states about Abraham:
And he believed in the Lord; and He counted it to him for
Man receives forgiveness of sin by faith in the death, burial and resurrection of Jesus Christ. So, righteousness is attained by receiving the grace of God (unmerited favor) by faith in the sacrifice of Christ. God had always intended that the only way to truly approach God and have a relationship with Him would be by His grace through faith.
So, Romans 9:30-31 just summarizes the results of both testaments and tells you that the Gentiles, who did not receive the law, who never had never even attempted to approach God through keeping the law have attained righteousness because the Gentiles were coming to God via faith in Chirst.
The Jews however, since they always attempted to approach God and attain His righteousness by their own work through attempting to live by the Commandments and the Law of Moses, stumbled at the stumblingstone (the Law) and did not seek God’s righteousness by receiving the Grace of God through faith in Jesus Christ. Hence they did not obtain God's righteousness.