In the ancient Greek plays, it was not uncommon for a protagonist to be saved from a dangerous situation or relieved from an impossible dilemma by the emergence of a deus ex machina ("god from the machine"), a plot device whereby the seemingly unsolvable problem is suddenly and abruptly resolved by the contrived and unexpected intervention of some new event or character, usually a god or hero. This was usually resorted to when the playwright had painted himself into a corner, so to speak, and could find no other way to resolve his contorted plot than by having some god emerge to miraculously set everything right. The deus ex machina was soundly criticized by the ancients as evidence of poor writing. In the history of modern thought, religion has been similarly criticized as a kind of philosophical deus ex machina, a device that is used to satisfactorily resolve the mysteries of the universe. Where does rain come from? God makes it. Where do earthquakes come from? God makes them. How does gravity work? God does it. Relying on religion to explain the physical properties of the universe in terms of direct acts of God is also known as a "God of the Gaps" theory.
Let us examine this concept of religion as serving a deus ex machina role with regard to the creation. Does religion really fulfill this function? If so, is this detrimental to arguments in favor of God's existence?
The basic premise of the "God of the Gaps" argument is that belief in a supernatural deity serves as a kind of "stop-gap" measure to explain physical phenomenon whose scientific explanations are not yet fully understood. In some primitive cultures, almost all physical phenomena are attributed to gods or spirits; so in ancient Egypt, the oar does not move the boat - the movement of the oar is in itself a magic spell which convinces the river god to move the boat.
As civilization progresses, the "magical" or supernatural explanations for certain phenomena are abandoned as empirical knowledge advances, while other, more mysterious or rare occurrences remain the province of the divine. For example, in ancient Rome, it was well known that rain was the result of the clouds reaching a saturation point, and that water that had reached the earth as rain would return to the air in the form of condensation; the scientific process known as the "water cycle" was well understood. Yet comets remained frightful portents of divine judgments, and stars were believed to be divinities.
Finally civilization reaches a turning point where all or most observable phenomena can be explained as the results of empirical processes, but what's more, even events whose cause is unknown are presumed to have completely empirical explanations. Thus in our modern age, everything from the tides to the movement of the stars to the working of the human brain are understood in terms of science; and even phenomena that are still mysterious (such as the indeterminacy of matter at the quantum level, for example) are still presumed to have materialist explanations, even if they are as of yet unknown. Therefore, society ultimately reaches a point where religious explanations for phenomena are no longer necessary. Religion is therefore a sort of causal explanation of the world that is ultimately transitory and must continue to graciously give ground and pass away before the advance of science. God is useful for filling in gaps in scientific knowledge, but as we fill in these gaps, His usefulness continues to wither away until it makes sense to discard Him altogether.
It cannot be denied that primitive cultures have utilized religion in this sense. In fact, most pagan religions have a strong element of identifying God with the powers of nature, such that the strike of lightning or the ripeness of the harvest are themselves divine actions, attributable to this or that god or goddess who are personifications of the powers of nature. This is a defining element of paganism. So we cannot deny that divinity has often been invoked as a stop-gap explanation in primitive paganism. Even in folk Christianity this has often been the case, although recourse to God as a deus ex machina explanation is much, much less common in the regions influenced by Greco-Roman tradition than secularists would have us believe. When God is invoked to explain something in creation, it is typically on a very fundamental, almost metaphysical level, as evidence by St. Augustine's elaborate theories on the acts of God upon prime matter in the latter books of Confessions.
Even so, the fundamental point the theist must make to the skeptic on this point is that, while the idea of God has been utilized as a deus ex machina explanation for physical events, this does not represent the essence of religious belief itself. Fundamentally, man does not naturally seek God as an explanation of how the universe works, but to account for the fact of the universe itself. God is not a deus ex machina mechanism explaining some functionality of the world; rather He is primarily a fons entis, a "source of being", explaining the existence of the world itself.
One fundamental error in the skeptic's argument is in assuming that empirical knowledge and belief in divine providence are antithetical. God, however, is the First Cause of the universe; this universe is operated through secondary causes - the causal interaction of different parts of the creation which truly bring about certain effects. The fact that these effects have natural causes does not mean they do not all come from God or serve His plan. One could define science itself as the study of the secondary causes of things. To say God acted it not to suggest an occurrence was necessarily supernatural or outside of the realm of the physical; in fact, more often than not it is just the opposite. The world is governed by Providence, and Providence can be defined as the means by which God uses secondary causes, even the free actions of rational agents, to bring about His designs infallibly. So on a strictly logical level, there need be no contradiction between empirical causality and divine Providence. The harvest does not cease to be "from God" just because we understand the growth cycle of crops. In fact, the natural working out of physical laws is the manner in which God brings about His Providence.
This brings us to the second point: What the idea of God gives to the universe is not a material explanation for phenomena, but a "directedness" to them, what the Greeks called a telos, an end. The telos corresponds to the question "Why?" To what end was this world constituted? Empirical science may tell us what the stars are made of, but they cannot tell us the purpose of the stars - why they exist, and why they should exist rather than not exist. We call to mind the distinction drawn by C.S. Lewis in Voyage of the Dawn Treader when Eustace and the "star at rest" Ramandu discuss the nature of the celestial bodies, and Ramandu corrects Eustace for taking a purely materialist view of the cosmos:
EUSTACE: "“In our world a star is a huge ball of flaming gas.”
RAMANDU: “Even in your world, my son, that is not what a star is, but only what it is made of.”"
Scientism has taught us that to explain what a thing is made out of is to explain what it is; yet this is a pitifully reductionist view of the world which leaves no place for a true teleology. In short, modern man neglects to acknowledge an Aristotelian "formal cause", an end for which creation was brought forth and towards which it tends. If it is the domain of science to provide mankind with material causes and empirical explanations for phenomena (secondary causes), then it falls exclusively to the realm of religion to provide man with teleological explanations for the universes (a primary cause). Science can answer "how", but it can never answer "why." At best it can ignore why, and at worst it can brush why away as irrelevant and meaningless.
We begin now to see the relationship between the idea of God and the scientific disciplines. God is the primary cause, the First Cause of all that exists - and note, in calling God the First Cause, we are not offering an explanation of how the universe came into being in the past (Aquinas' argument of the First Cause does not explain why things came into being in the past as much as explain why they have being right now). As the First Cause and the Omnipotent Lord of all Creation, God orders the universe as He wills, and causes it to operate according to certain principles in order to realize His will in time and space. The ways in which the universe operates are "secondary causes", secondary because they realize a higher teleological end. Thus the cosmos is a hierarchy of causation, with causation which is purely physical serving to help realize the final causation of God's telos.
In short, men did not invent gods for themselves primarily to explain natural phenomena; yes, that was certainly part of it, as we have seen. But the primary reason men have always groped and sought for God in the darkness (Acts 17:27) is because they recognized that the fact of the universe and its ordination towards mankind is unexplainable without a final cause, a telos, a "why." Primitive man may not have understood science, but he knew enough to understand that purely material forces can never answer the question, "Why?"
Furthermore, the question "Why?" remains no matter how technologically advanced society becomes; in fact, one could argue it becomes more profound as technology increases. This demonstrates that religion does not need to give ground before scientific discovery. Rather, it shows that religion and science are on two different planes entirely. Religion deals with primary causes on the metaphysical, ontological and teleological levels that can never be addressed by science, whilst science looks at secondary causes on the empirical and materialist level, which can certainly be encompassed by religion but are never understood as primary causes in and of themselves.
In God we find not a deus ex machina to explain physical conundrums, but a fons entis, a fountain of being, which offers a teleological explanation for being as such. And despite the noblest efforts of science, nobody can explain the bringing forth of being from non-being in solely materialistic terms. The workings of the universe can be explained by science, but the creation of the universe itself is a supernatural act that is not within the realm of science to explain. Not that we only posit a supernatural creation because we don't know the physical mechanism; rather, we understand a supernatural creation because no physical mechanism is possible. From nothing nothing comes, and no amount of empirical study can ever alter this fact.
Every single scientific question in the universe can be answered and man's fundamental religious longings will still be left unsatisfied.