You say this blessing out loud in shul if you have emerged from any one of four potentially threatening events, a dangerous journey, a sea voyage, illness (even if not life threatening) and imprisonment. We thank God for saving us from danger, even if we are unworthy, and the rest of the community responds by giving thanks together.
Hagomel gives women an opportunity for public participation in Orthodox services: it is common for women who have recently given birth to come and say the blessing in shul as soon as they are able.
Some people say hagomel after taking a long air flight, despite the statistics that crossing the Atlantic by plane is somewhat less dangerous than crossing your local high road. Even in the Middle Ages, the Shulchan Aruch writes that people did not bless hagomel after a journey in France or Germany, because the roads were reasonably safe, unlike in Spain, where travellers took their lives in their hands. Still, flying feels to many people to be more dangerous than crossing the road and if the experience moves them to give thanks, then why not?