The Jews observed a rule borrowed from the Code of Hammurabi, which was applied by the neighboring nations, but which was in no way stipulated in the law of Moses.
When the wife in a couple was barren, she could ask her husband to sleep with her servant or slave. The child born of this union was then recognized as legitimate and thus guaranteed posterity. He was even considered the son of the infertile wife, the servant being merely a surrogate mother.
This method was used in order to increase the number of descendants, as was the case with Jacob (Genesis 29.31).
Sarah's proposal to Abraham, her husband, was in keeping with the Code of Hammurabi practiced at that time, but did not correspond to what God had said and promised to Abraham.