Abraham did sleep with Hagar, but there is no suggestion that God allowed it. Abraham and Sarah probably had a lack of trust in God.
Anyway, here goes my analysis of the scriptures…
The Jewish patriarch Abram and Sarai were childless (Gen 15:2), but God promised Abram that they would have a son whose descendants would become a great nation (Gen 15:5). Unfortunately, the years went by and Sarai failed to fall pregnant. In ancient cultures without modern science, it was believed to be the woman’s fault and her humiliation if she couldn’t produce a child. So, in order to fulfill God’s promise, she proposed to Abram that he have a child by her Egyptian servant, Hagar, and they agreed (Gen 16:2). (Such is surrogacy, 2000 B.C. style…)
When Hagar became pregnant, she became proud and despised Sarai (Gen 16:4). Then Sarai treated Hagar so cruelly she ran away (Gen 16:6). Hagar was so distressed that God comforted her and told her to go back, and that her son will be named Ishmael and have many descendants, but He warned her that her son would be wild and against everyone, and everyone will be against him (Gen 16:7-12). Abram, who was a wealthy man (Gen 12:5), accepted Hagar again, and he thought Ishmael was the promised son (Gen 16:15), so he raised Ishmael as a prince; the heir apparent. But when Ishmael was a teenager, God appeared to Abram to reveal His covenant (Gen 17:4). God changed Abram’s and Sarai’s name to Abraham and Sarah (Gen 17:5,15), and would now give them the promised son (Gen 17:16) and his name will be Isaac (Gen 17:19). Abraham asked if Ishmael could be the heir (Gen 17:18), but this was not God’s plan. However, God told Abraham that He will make Ishmael the father of twelve princes and make great nations of those descendants (Gen 17:20). And so, Isaac would become the father of the Israelites (Gen 25:19, 35:10-11), and Ishmael would become the father of the Arabs (Gen 25:12-16,18; Ga 4:25).
When Isaac was born, Sarah ordered for Hagar and Ishmael to be sent away because she wanted the full inheritance to go to Isaac (Gen 21:10). What a crushing blow to Ishmael. And so the Arab-Israeli conflicts begin (Gen 25:18); a family feud, fuelled by jealousy - a situation borne of a lack in the promises of God.