The wiktionary web site lists the following synonyms for the phrase "for fuck's sake"
for goodness sake
for mercy's sake
for pity's sake
for God's sake
for Pete's sake
for Christ's sake
The Oxford dictionary has fuck, used as an exclamation,
Used alone or as a noun or verb in various phrases to express annoyance, contempt or impatience
In the case of
Thank fuck you're still alive
the underlying sentiment is to thank God, but the speaker avoids saying God because he or the person he is speaking to may not believe in Him or that He was responsible for the preservation of life.
He could say
Thank your lucky stars
but again they may not believe in astrology.
By using the word fuck rather than God, your lucky stars, Lady Luck, the laws of science, or any similar expressions, the speaker avoids any overtly religious or philosophical implications about the reason the person is still alive.
The whole realm of theology, philosophy and science, whoever or whatever has kept the person alive, is conjured up by the simple word "fuck", without attempting to articulate a belief or theory about what "fuck" may be.
In the phrase
for fuck's sake
something similar is meant, but has the advantage of carrying an emphatic meaning. There may be also a reluctance to use the word God, for example, to avoid any suggestion of blasphemy.
For God's sake, get me another beer.
could seem somewhat blasphemous. "Fuck" avoids any implication that fetching the beer is a religious duty.
One would not, of course, substitute "fuck" for "God" in Church, or when having tea with the vicar.