After these things the word of the Lord came to Abram in a vision, saying, “Do not be afraid, Abram. I am your shield, your exceedingly great reward.”
But Abram said, “Lord God, what will You give me, seeing I go childless, and the heir of my house is Eliezer of Damascus?” Then Abram said, “Look, You have given me no offspring; indeed one born in my house is my heir!”
And behold, the word of the Lord came to him, saying, “This one shall not be your heir, but one who will come from your own body shall be your heir.” Then He brought him outside and said, “Look now toward heaven, and count the stars if you are able to number them.” And He said to him, “So shall your descendants be.”
And he believed in the Lord, and He accounted it to him for righteousness.
Then He said to him, “I am the Lord, who brought you out of Ur of the Chaldeans, to give you this land to inherit it.” (Genesis 15:1-7)
Abram was an old man; his wife was an old woman. Despite a successful and prosperous life, something important was lacking. Abram was not slow to let God know his disappointment. For the ancient Jewish people, nothing was more important to them than having heirs to carry on their names. Abraham would do anything for a proper heir.
Therefore, given the customs and laws in the place where Abram lived, Abram had acted. A childless couple could designate one of their servants as their heir, giving that servant what amounted to the rights and privileges of a firstborn son, until and unless they had their own child, in which case the rights and privileges of a firstborn son would revert to the actual biological child.
When God tells Abram that the designated heir would be unnecessary because Abraham would have a flesh and blood son, Abram’s reaction was joy and to believe what God had told him.
Because he believed, God considered Abraham to be righteous. In the New Testament, Paul makes much of this incident, explaining in Galatians 3:1-6 that righteousness is not in how people act, but in their belief in what Jesus accomplished on the cross.