The story contains three characters: Abraham, Abimelek, and God.
Abimelek or Abimelach was a pagan king who took in Abraham and Sarah as they wandered through the Negev. His city Gerar is thought to be Tel Haror or Tell Jemmeh (Gama). These were fortified cities of the Middle Bronze-Age II period, around 1800 BCE.
Abimelek takes Sarah as his wife but does not lie with her. In fact, when he took Sarah, a curse was upon his house: his wife and concubines are stricken barren when Abimelek takes Sarah as his wife.
We’ll meet Abimelek again in the story of Isaac when Isaac presents his wife Rebekah as his sister as well.
Abimelek is a polytheistic king who was spoken to by Yahweh. He did the right thing when he realized Sarah was Abraham’s wife: giving Abraham sheep, cattle and slaves, and a thousand shekels of silver to restore Sarah’s honor.
We have Abraham as a deceiver, Abimelek as a pagan who’s tricked, is spoken to by God, then corrects his offense to Sarah. The honor of a man’s wife is very important and Abimelek’s honor is important to. He makes a grand gesture to display his innocence.
In the larger story of Genesis, we have the following:
The Primeval period: from creation to the flood – Genesis 1 through 11
Abraham – Genesis 12 through 20
Isaac – Genesis 21 – 25
Jacob – Genesis 26 through 50
We know the Primeval section comes from Sumerian mythology. Abraham in Israel/Jordan takes place in the Middle Bronze Age.