Lot was Abraham's nephew. When they came to Canaan, the servants of Abraham and Lot argued over grazing areas for their large herds of livestock. Abraham and Lot agreed to part ways, with Abraham giving Lot first choice of land. Lot chose the land of the plain of Jordan, near Sodom and Gomorrah, because of the rich pastureland there. Abraham settled near Hebron (Genesis 13). Lot’s choice proved to be a foolish one, as the wickedness of Sodom was very great (verse 13). The grass was greener near Sodom, but greener is not always better.
God had determined to destroy Sodom and Gomorrah for the wickedness of the inhabitants (Genesis 18:16–33). Two angels warned Abraham’s nephew Lot to evacuate the city so he and his family would not be destroyed.
The angels told Lot to escape from Sodom, to flee to the hills before the impending destruction of Soddom and Gomorrah by sulfur and fire. Lot begged to be allowed to flee to a little city (subsequently named Zoar, a name which means 'little'). All the cities in the valley were destroyed.
Why did Lot subsequently leave the small city of Zoar and end up living in a cave in the mountains? Because he was afraid. The English Standard Version Study Bible makes this comment:
Although Lot had asked to escape to Zoar (v. 20, 22), the destruction of the valley fills him with such fear that he leaves the city and moves away to live in the hills. There he and his daughters inhabit a cave. Archaeological surveys have revealed that caves around the Dead Sea often served as places of refuge.
The path to Sodom seemed right to Lot, but it almost cost him his life. The road to Zoar seemed right to Lot, but again, he made a poor choice. Unlike his uncle Abraham, Lot did the things he did because he chose to live in his old sin nature and do what was easy, and he made choices to flirt with evil instead of living to honor God.