it's a good thing (that)(also it's a good job (that) ) used when saying that there would have been problems if something had not happened
 [TahlilGaran] Dictionary of Contemporary English ▲
 lucky happening because of good luck, or bringing you good luck: 
 a lucky guess
 a lucky guess  Seven is considered a lucky number.
 Seven is considered a lucky number.  It’s lucky that I’ve got some spare keys.
 It’s lucky that I’ve got some spare keys.  Italy got a lucky goal in the last five minutes of the game.
 Italy got a lucky goal in the last five minutes of the game.  ‘How did you know he’d be there?’ ‘It was a lucky guess.’fortunate
 ‘How did you know he’d be there?’ ‘It was a lucky guess.’fortunate happening because of good luck. 
Fortunate is more formal than 
lucky: 
 It was extremely fortunate that there was no one in the building when the bomb went off.
 It was extremely fortunate that there was no one in the building when the bomb went off.  I’m in the fortunate position of doing a job I love.
 I’m in the fortunate position of doing a job I love.  Some plants actually prefer a lot of shade, which is fortunate for gardeners choosing plants for gloomy corners.it’s a good thing (that)
 Some plants actually prefer a lot of shade, which is fortunate for gardeners choosing plants for gloomy corners.it’s a good thing (that) (
also it’s a good job (that) British English)
 spoken used when saying that there would have been problems if something had not happened: 
 It’s a good thing that you brought an umbrella with you.
 It’s a good thing that you brought an umbrella with you.  It’s a good job I’m here to help.miraculous
 It’s a good job I’m here to help.miraculous extremely lucky in a way that is almost unbelievable: 
 A teenager had a miraculous escape last night when the car she was travelling in overturned.
 A teenager had a miraculous escape last night when the car she was travelling in overturned.  The doctor gave her a month to live but she made a miraculous recovery.
 The doctor gave her a month to live but she made a miraculous recovery.  It was miraculous that no one was seriously injured in the accident.fortuitous
 It was miraculous that no one was seriously injured in the accident.fortuitous /fɔːˈtjuːətəs $ fɔːrˈtuː-, fɔːˈtjuːɪtəs $ fɔːrˈtuː-/
 formal happening because of good luck: 
 a fortuitous decision
 a fortuitous decision  a fortuitous coincidence
 a fortuitous coincidence  It was fortuitous that no one else was hurt.a fluke
 It was fortuitous that no one else was hurt.a fluke /fluːk/
 informal something that happens by chance, not because of skill or good judgement: 
 The goal was a fluke.
 The goal was a fluke.  By a fluke, he managed to get the question right.be in the right place at the right time
 By a fluke, he managed to get the question right.be in the right place at the right time used when saying that someone is lucky and the situation is right for them: 
 Making money from buying property is easy – you just have to be in the right place at the right time.
 Making money from buying property is easy – you just have to be in the right place at the right time. [TahlilGaran] English Thesaurus ▲