In the times of the Beit Hamikdash, a person who survived a potentially life-threatening situation brought a Korban Todah, a Thanksgiving Offering, to express his gratitude to Hashem. Nowadays, when the Beit Hamikdash no longer stands and offerings cannot be brought on the altar, we substitute a public proclamation of gratitude to Hashem for an offering. A survivor from a life endangering situation as defined by the Gemara recites Birkat Hagomel in gratitude.
The Gemara Brachot 54b states: "One who has completed a sea voyage; one who has traveled through the desert; one who has been sick and healed; and one who was imprisoned and freed."
- Vayikra 7:12