This appears to be a paraphrase and exaggeration of East-West Divan, which contains lines like:
Only by the term of the One / He mastered the whole world (Nur durch den Begriff des Einen / Hat er alle Welt bezwungen)
In East-West Divan, Goethe was in-character as a Muslim. From time to time in his literary career he would imagine what it would be like to live as a Muslim, attempting to see through the eyes of the Other without casting judgment; there is also such a discussion in Eckermann's Conversations with Goethe, where he imagines the psychological impact of the Islamic education system.
"But it is very interesting to see what Muslims are taught at the start of their education. As the basis of their religion, their young people are taught to believe that nothing can happen to a man that was not decreed long ago by an all-seeing divinity; this equips them for the rest of their lives and sets their minds at rest, and they hardly need anything else. / It’s not for me to say whether this doctrine is true or false, helpful or harmful, but at bottom there is something of this belief in all of us, even though we have not been taught it..." (Blunden translation, 2022)
As Goethe more explicitly states here, he employs a methodological relativism to see the human truths in other cultures. And the common reading of East-West Divan is that he is doing the same thing there.
So, it is incorrect to cite East-West Divan as Goethe's own beliefs, and in any case this is apparently a false quotation based on someone's exaggeration of its contents; I can't trace it back any earlier than 2008.
However, there are Muslims who have consulted Goethe's private writings and letters and believe him to have accepted Islam. A fatwa was issued in 1995 listing many such examples of actual writings by Goethe and not including this quote. These Muslims interpret East-West Divan as a purposefully ambiguous text meant to conceal his faith behind literary conceit.