The first time I heard this phrase was a few decades ago and it was the punchline to a religious joke, which I won't repeat.
Whether that's the source, I can't say. I know it was a fairly common joke around that time, but...who knows? It's possible, I guess, that it permeated into the urban consciousness. Or it's origins could equally lie in something more mundane.
It's definitely been around for some time, though. Long, long before SG1 or Veggie Tales were gleams in their makers' eyes.
LabRat