Clearly, God’s promise to give the whole earth to Abraham and his descendants was based not on his obedience to God’s law, but on a right relationship with God that comes by faith. If God’s promise is only for those who obey the law, then faith is not necessary and the promise is pointless. For the law always brings punishment on those who try to obey it. (The only way to avoid breaking the law is to have no law to break!)
So the promise is received by faith. It is given as a free gift. And we are all certain to receive it, whether or not we live according to the law of Moses, if we have faith like Abraham’s. For Abraham is the father of all who believe.