Ontological Argument, in its initial verison as presented by Anselm of Canterbury is as follows,
The first ontological argument in Western Christian tradition[i] was proposed by Saint Anselm of Canterbury in his 1078 work, Proslogion (Latin: Proslogium, lit. 'Discourse on the Existence of God'), in which he defines God as "a being than which no greater can be conceived," and argues that such being must exist in the mind, even in that of the person who denies the existence of God. From this, he suggests that if the greatest possible being exists in the mind, it must also exist in reality, because if it existed only in the mind, then an even greater being must be possible—one who exists both in mind and in reality. Therefore, this greatest possible being must exist in reality. Similarly, in the East, Avicenna's Proof of the Truthful argued that there must be a "necessary existent"
There have been, since many variants of ontological arguments, but they all have one common idea, that the God is the greatest entity that can be conceived.
Problem of evil is an ancient problem.
Possibly originating with Greek philosopher Epicurus (341–270 BCE),[38] Hume summarizes Epicurus's version of the problem as follows: "Is God willing to prevent evil, but not able? Then he is not omnipotent. Is he able, but not willing? Then he is malevolent. Is he both able and willing? Then from whence comes evil?"
To answer this problem of evil many theodicies have come, they use free will argument, greater good argument and human ignorance about it, etc.
But, whatever maybe the theodicy, any reasonably imaginative intelligent person can easily conceive of Universe, with no evil or way less evil, which is a greater Universe than the current one and then therefore a God who creates a Universe with no or comparatively little evil which is not rife with horrendous human and animal suffering and still has good things like free will, happiness etc. would be a greater God
Now coming back to ontological arguement, and rephrasing it,
We can concieve a God who can create the Universe with no or little evil in it. Since such a God would be great, if that God exists in both mind and reality, therefore such a God indeed exists in relaity, and is greater than the God of this current Universe.
But we don't have less evil Universe. We have the Universe where comparatively more suffering exists. So this argument cannot establish a maximally good God, because maxiamlly good God would have created a better Universe. So here problem of evil seems to disprove ontological argument. Is this argument acknowledged and are there any criticisms to it?
P.S: I'm trying to explore specifically how problem of evil impacts ontological argument. I'm not trying to just disaprove ontological argument.
Edit: Many people in the comment section are struggling to imagine a better universe than ours along with free will. This makes me second guess my assumption that anyone can easily comprehend a better universe. Anyway I argue that it is indeed possible to create a Universe which has far less suffering and far less pain. This suffering and pain by all is what is termed as evil. I will try to contrast a better universe just as an example of what I'm trying to say. Please note, we don't have to come up with the best universe possible, we just have to come up with a slightly better universe than the one we have. The very fact we don't have the slightly better universe is enough to disprove the ontological argument.
First we have the current world with free will, which itself many people do not agree is actually present, nevertheless for argument sake let's assume this universe of ours has free will, but is also filled with human and animal suffering. In our universe we have free will not total freedom. Many people keep confusing free will with freedom. Free will is the property of innermost core of one's mind. A paralysed guy has the same amount of free will which a rich healthy person has. A human being is only free to make choices, can also think if mentally healthy and move his or her body if physically healthy. That's all there is to free will. It says nothing about the laws of Universe, of cancer and other diseases, of natural disasters etc. A human can control only his mind and body which he has been given at birth. He doesn't have any control over external laws and instead is subject to them, so it is therefore possible to retain all the elements of freewill, that is control over mind and body at best but change the external laws to create a better Universe.
Imagine a Universe, where there is free will, just like ours, where everyone lives till 100, after everyone reaches 25, they stop, aging, no cancer or any other diseases, can eat anything and be healthy like people with good metabolism already do. No kids with cancers or horrific diseases. No Animal suffering as all animals are in controlled environment and are happy. And if things go wrong politically like a dictator takes over, immediately God comes and takes him out, note this is not interferring with free will, as God has striked many sinners in the past. People can't get murdered as anyone less than 100 years can be revived. This seemingly kiddish imagination of mine is arguably already way way better than the current Universe, even though this imaginative Universe may not be the best there is, but definitely a way better Universe than the current one, with free will. The very fact that we don't have this Universe proves that ontological argument cannot be used to establish a maximally good God. We don't have to even imagine where the changes I have imagined is strictly true, just a trend towards that direction is already a better Universe than the current one. If you have any doubt whether the Universe I have imagined is not the better one than our current Universe, just ask yourself in which one would you like to live.