For the promise that he would be the heir of the world was not to Abraham or to his seed through the law, but through the righteousness of faith. (Romans 4:13)
The promise God made to Abraham was not through the law but through the righteousness of faith.
Certainly, the law of Moses had not yet been put in place when God made the promise to Abraham in Genesis 12:1-3. But remember that Paul has been using the word “law” in reference to sinless or flawless living.
Either way - the promise to Abraham and his seed was not through the “law.”
Abraham and his descendants.
Abraham and all of his descendants who seek after righteousness based on faith, as he did, are the heirs of the world (in contrast to those who live by the Law). They are the true seed. - Pollard, Truth for Today Commentary, 149
Paul just mentioned in the previous verses that the blessings of the gospel are for everyone - not just the Jewish people.
God’s promise to Abraham is for all those who demonstrate the same kind of faith as Abraham.
In Paul’s thought, ethnic, national Israel would never rule the world. God would, and He would do it through the Jewish Messiah, Jesus. By Him, all the nations would be brought equally into God’s family. - Pollard, Truth for Today Commentary, 149
To try and be justified by the Law or by sinless living would be to miss out on the promise God made to Abraham and his descendants - for it comes by the righteousness of faith.
Paul is in the middle of making a rather strong point - those who reject Jesus Christ and the gospel are also refusing the promise God made to Abraham and his descendants.
To reject Jesus is also to refuse to have the kind of faith that Abraham and David had (Romans 4:1-9).
The promise is not for a particular race of people - the promise is for all those with the same humble, obedient faith as Abraham.