In most religions, God is an omnipotent, omniscient, and generally perfect being.
Mathematicians simply borrowed that definition. For example, Rubik's cube "God's number" is 20. Because, of course, God, as an omniscient, omnipotent perfect being will solve the puzzle in the minimum possible amount of moves. And that number is 20 in the most complex case.
Computer science have a similar, more formal concept with oracles. An oracle is a machine that can quickly solve a problem. How it does it is not the question, it can be supernatural, but we simply assume that such a machine exists in order to study some theoretical problems.