Berkeley’s philosophy is built around the insight that the existence of matter and the existence of God are incompatible. If God exists, then matter does not; if matter exists, then God does not. This incompatibility is not obvious: offhand it appears that matter and God are compatible entities—a world could contain both. Without rehearsing all of Berkeley’s reasoning, his basic points are as follows. First, the idea of matter leads to skepticism about both the ordinary perceptible world and about the existence of God. This is because matter is conceived as existing outside the mind and hence subject to doubt; and matter makes the existence of God look redundant in the running of the world, since matter is conceived as the cause of both mental and physical events. By contrast, according to Berkeley’s theocentric immaterialism, God is critical to the organization of the world, being not only its original author but also the cause of everything that happens in our minds. In Berkeley’s metaphysics God is the center of all reality, not a mere adjunct to matter, which is conceived as an active power. Second, we have no clear conception of matter, which leaves us ignorant of the world we think we know, whereas we do have a clear conception of mind (ideas, spirits). Why would God leave us in ignorance of the world? Why create a world that we neither know nor understand? God had the option of creating a completely immaterial world, built according to Berkeley’s specifications, so why would he create a world with matter in it? That would only lead to religious skepticism and the impossibility of human knowledge of the commonsense world. Why create a type of reality that leads inevitably to atheism? Surely God would create a world in which he plays a crucial metaphysical role, as he does in Berkeley’s idealism. A world of matter is not a world that any God worthy of the name would create. There is no sense in the idea of matter, according to Berkeley, so God would not create a world containing it; he would create an intelligible world. Hence, if we know that God created a certain world, then we know that that world contains no matter; and if a world contains matter, then we know it contains no God. But an immaterial world can certainly contain God, and God can intelligibly create a world containing only ideas and spirits. God and the immaterial go harmoniously together, but God and the material make an impossible pairing. For Berkeley, materialism in this sense is not part of common sense, though of course there are real objects of perception; it is a philosopher’s invention—an invention with impious consequences. He thinks he can dispense with it in favor of his own idealist ontology, and good riddance. We can thus save knowledge and religion from the dangers inherent in the metaphysics of material substance.
On this view of things, Descartes cannot consistently be a theist because he believes in matter defined to be non-mental in nature (i.e. extension). True, the mind is immaterial, but the objects of perception are taken to be material—he is a materialist about mountains, animal bodies, rocks, etc. This leads quickly to skepticism, since these things exist outside the mind (any mind); and it makes God causally redundant in the process of perception. God sits uncomfortably beside extended things twiddling his thumbs, in the Cartesian worldview. The cure is to give up the mythology of material things, according to Berkeley. He is quite clear that God exists, but God precludes matter, so there is no matter. Fortunately, we can construct an alternative metaphysics that is fully consistent with the existence of God. It is the idea of primary qualities that lies at the root of the anti-theist tendencies of materialism: for these are qualities that are instantiated independently of the mind, thus generating skepticism. Once we admit primary qualities we have allowed for realities that threaten to upset commonsense knowledge and are theologically unsound—remote causes of perception that are inconsistent with God’s beneficence. So Berkeley rejects the distinction between primary and secondary qualities, rating all qualities “in the mind”. Before Descartes based his physics on the materialist view of sensible objects it was possible to pursue a physics consistent with the existence of God, but once the concept of matter (mindless stuff) was introduced into the heart of physics God was eliminated from the picture—and no amount of immaterialism about the mind could find a rightful place for him. Instead we need a physics freed from the myth of materialism about the (so-called) physical world, such as Berkeley suggested. Of course it is logically open to us to reject God and make do with matter, instead of rejecting matter and making do with God: but the point is that such a decision has to be made. What we can’t do is combine theism with materialism about the physical (sic) world. That has been the standing position, more or less, since Descartes carved things up as he did; but Berkeley points out that such a position is unstable. It’s either matter and atheism or mind and theism.
 He says in the Dialogues (206): “there is not perhaps any one thing that has more favored and strengthened the depraved bent of the mind toward atheism, than the use of that general confused term [“matter”]. Also (202): “But allowing matter to exist, and allowing the notion of absolute existence to be as clear as light; yet was this ever known to make the Creation more credible? For has it not furnished the atheists and infidels of all ages, with the most plausible argument against a Creation?” In the Preface we read (118): “If the principles, which I here endeavor to propagate, are admitted for true; the consequences which, I think, evidently follow from thence, are, that atheism and skepticism will be utterly destroyed”. (I am using the Penguin edition, 1988).