There are many different types of necessity.
Logical Necessity and the Ontological Argument
A logically necessary entity exists in every possible world. (A “possible world” is just a logically possible state of affairs.) That is, there is no logically possible state of affairs in which a logically necessary entity does not exist.
The ontological argument seeks to demonstrate, among other things, that God is a logically necessary entity. Since God is the greatest possible being, there is no logically possible state of affairs in which God does not exist. It is greater for God to exist in every possible …