One of the odd things in Genesis is that there are two similar stories about how Abraham pretends to be Sarah’s brother instead of her husband, out of fear of a king who admires her beauty. In Genesis 12 [+/-]Genesis 12
[12:1]Now the LORD said to Abram, "Go from your country
and your kindred and your father's house to the land that I
will show you. [2]And I will make of you a great nation,
and I will bless you and make your name great, so that you
will be a blessing. [3]I will bless those who bless you,
and him who dishonors you I will curse, and in you all the
families of the earth shall be blessed."
[4]So Abram went, as the LORD had told him, and Lot went
with him. Abram was seventy-five years old when he departed
from Haran. [5]And Abram took Sarai his wife, and Lot his
brother's son, and all their possessions that they had
gathered, and the people that they had acquired in Haran,
and they set out to go to the land of Canaan. When they
came to the land of Canaan, [6]Abram passed through the
land to the place at Shechem, to the oak of Moreh. At that
time the Canaanites were in the land. [7]Then the LORD
appeared to Abram and said, "To your offspring I will give
this land." So he built there an altar to the LORD, who had
appeared to him. [8]From there he moved to the hill country
on the east of Bethel and pitched his tent, with Bethel on
the west and Ai on the east. And there he built an altar to
the LORD and called upon the name of the LORD. [9]And Abram
journeyed on, still going toward the Negeb.
[10]Now there was a famine in the land. So Abram went
down to Egypt to sojourn there, for the famine was severe
in the land. [11]When he was about to enter Egypt, he said
to Sarai his wife, "I know that you are a woman beautiful
in appearance, [12]and when the Egyptians see you, they
will say, 'This is his wife.' Then they will kill me, but
they will let you live. [13]Say you are my sister, that it
may go well with me because of you, and that my life may be
spared for your sake." [14]When Abram entered Egypt, the
Egyptians saw that the woman was very beautiful. [15]And
when the princes of Pharaoh saw her, they praised her to
Pharaoh. And the woman was taken into Pharaoh's house.
[16]And for her sake he dealt well with Abram; and he had
sheep, oxen, male donkeys, male servants, female servants,
female donkeys, and camels.
[17]But the LORD afflicted Pharaoh and his house with
great plagues because of Sarai, Abram's wife. [18]So
Pharaoh called Abram and said, "What is this you have done
to me? Why did you not tell me that she was your wife?
[19]Why did you say, 'She is my sister,' so that I took her
for my wife? Now then, here is your wife; take her, and
go." [20]And Pharaoh gave men orders concerning him, and
they sent him away with his wife and all that he had. (ESV)

the king is the Pharaoh of Egypt, and in Genesis 20 [+/-]Genesis 20
[20:1]From there Abraham journeyed toward the territory
of the Negeb and lived between Kadesh and Shur; and he
sojourned in Gerar. [2]And Abraham said of Sarah his wife,
"She is my sister." And Abimelech king of Gerar sent and
took Sarah. [3]But God came to Abimelech in a dream by
night and said to him, "Behold, you are a dead man because
of the woman whom you have taken, for she is a man's wife."
[4]Now Abimelech had not approached her. So he said, "Lord,
will you kill an innocent people? [5]Did he not himself say
to me, 'She is my sister'? And she herself said, 'He is my
brother.' In the integrity of my heart and the innocence of
my hands I have done this." [6]Then God said to him in the
dream, "Yes, I know that you have done this in the
integrity of your heart, and it was I who kept you from
sinning against me. Therefore I did not let you touch her.
[7]Now then, return the man's wife, for he is a prophet, so
that he will pray for you, and you shall live. But if you
do not return her, know that you shall surely die, you and
all who are yours."
[8]So Abimelech rose early in the morning and called all
his servants and told them all these things. And the men
were very much afraid. [9]Then Abimelech called Abraham and
said to him, "What have you done to us? And how have I
sinned against you, that you have brought on me and my
kingdom a great sin? You have done to me things that ought
not to be done." [10]And Abimelech said to Abraham, "What
did you see, that you did this thing?" [11]Abraham said, "I
did it because I thought, There is no fear of God at all in
this place, and they will kill me because of my wife.
[12]Besides, she is indeed my sister, the daughter of my
father though not the daughter of my mother, and she became
my wife. [13]And when God caused me to wander from my
father's house, I said to her, 'This is the kindness you
must do me: at every place to which we come, say of me, He
is my brother.'"
[14]Then Abimelech took sheep and oxen, and male
servants and female servants, and gave them to Abraham, and
returned Sarah his wife to him. [15]And Abimelech said,
"Behold, my land is before you; dwell where it pleases
you." [16]To Sarah he said, "Behold, I have given your
brother a thousand pieces of silver. It is a sign of your
innocence in the eyes of all who are with you, and before
everyone you are vindicated." [17]Then Abraham prayed to
God, and God healed Abimelech, and also healed his wife and
female slaves so that they bore children. [18]For the LORD
had closed all the wombs of the house of Abimelech because
of Sarah, Abraham's wife. (ESV)

it is the king of Gerer. In both stories, Abraham acts despicably. It’s natural to suppose that the compiler of Genesis wrote in two versions of the same story. But I realized, in thinking of how bad Abraham’s behavior was, that this evil provides an alternative reasonable explanation: Abraham saw that the deceit worked, and repeated it. He was afraid of Pharaoh, pretended to be Sarah’s brother, and survived. So, being afraid of the king of Gerer, he did it again, knowing that God would pull his chestnuts out of the fire.
This puts Abraham in an even worse light, but Abraham is just one of the many flawed “good guys” in the Bible. Jacob, David, and Peter are three others. There’s also Genesis 16 [+/-]Genesis 16
[16:1]Now Sarai, Abram's wife, had borne him no
children. She had a female Egyptian servant whose name was
Hagar. [2]And Sarai said to Abram, "Behold now, the LORD
has prevented me from bearing children. Go in to my
servant; it may be that I shall obtain children by her."
And Abram listened to the voice of Sarai. [3]So, after
Abram had lived ten years in the land of Canaan, Sarai,
Abram's wife, took Hagar the Egyptian, her servant, and
gave her to Abram her husband as a wife. [4]And he went in
to Hagar, and she conceived. And when she saw that she had
conceived, she looked with contempt on her mistress. [5]And
Sarai said to Abram, "May the wrong done to me be on you! I
gave my servant to your embrace, and when she saw that she
had conceived, she looked on me with contempt. May the LORD
judge between you and me!" [6]But Abram said to Sarai,
"Behold, your servant is in your power; do to her as you
please." Then Sarai dealt harshly with her, and she fled
from her.
[7]The angel of the LORD found her by a spring of water
in the wilderness, the spring on the way to Shur. [8]And he
said, "Hagar, servant of Sarai, where have you come from
and where are you going?" She said, "I am fleeing from my
mistress Sarai." [9]The angel of the LORD said to her,
"Return to your mistress and submit to her." [10]The angel
of the LORD also said to her, "I will surely multiply your
offspring so that they cannot be numbered for multitude."
[11]And the angel of the LORD said to her,
"Behold, you are pregnant
and shall bear a son.
You shall call his name Ishmael,
because the LORD has listened to your affliction.
[12]He shall be a wild donkey of a man,
his hand against everyone
and everyone's hand against him,
and he shall dwell over against all his kinsmen."
[13]So she called the name of the LORD who spoke to her,
"You are a God of seeing," for she said, "Truly here I have
seen him who looks after me." [14]Therefore the well was
called Beer-lahai-roi; it lies between Kadesh and Bered.
[15]And Hagar bore Abram a son, and Abram called the
name of his son, whom Hagar bore, Ishmael. [16]Abram was
eighty-six years old when Hagar bore Ishmael to Abram. (ESV)

, where Abraham cravenly abandons Hagar when Sarah changes her mind. Abraham, the symbol of Faith and Promise, doesn’t become a hero of faith until chapter 22, with the sacrifice of Isaac.