When is a hallucination the best explanation?
We have a fairly good idea of when and how experiences are unreliable. Just off the top of my head:
- When you experience something while in bed in the middle of the night: Dreams would be the obvious example, and the line between dream and reality isn't always that definitive, and sleeping involves multiple brain processes working together, which don't always align perfectly, e.g. sleep walking or sleep paralysis, which frequently involves hallucinations.
- When you have a relevant illness. Mental illnesses, absolutely, but illnesses generally could also apply. For example, fever can cause vivid "fever dreams" that someone could conceivably mistake with reality or something more than just a dream, especially if they don't commonly experience vivid dreams.
- When you've suffered a brain injury.
- When you generally have a loose grasp of reality. This one's a bit hard to directly argue: if someone sees things all the time that others don't consider to exist, they could merely say all of that actually exists in some other realm. Although one could argue whether they, or anyone else, are justified in believing that to be the case.
- When you're on drugs (recreational or prescribed) with potential hallucinogenic properties.
- When you see something in the corner of your eye, when you see some vague shape in the dark, when you hear some voice in your head, etc.
In addition, memory is notoriously unreliable (especially during particularly emotional experiences, which commonly applies to claimed spiritual experiences). People especially frequently remember exaggerated versions of what actually happened (also especially during particularly emotional experiences, e.g. remembering one's abuser as larger than life). Never mind when they just consciously exaggerate, to try to convince someone of their preferred conclusion, or to make it sound more significant than it actually was. It may also be difficult to give someone a good idea of what you experienced (even if we're talking about e.g. seeing physical objects, but especially if we're talking about emotions and internal senses, which are common parts of spiritual experiences, although we can try to make sense of someone's described experience by relating it to our own experiences and the described experiences of others). So if someone says "I saw a cloud that spoke to me", one might reasonably interpret that as them having seen some dark spot in their vision and having had some thoughts* (but of course it depends on the details they offer).
* As a side note, not everyone thinks in words, so if someone has an experience of thinking in words when they haven't experienced that before, they may attribute some extraordinary explanation to that. Although, as a former religious person, who does think in words, I know how easily people (my former self included) attribute their thoughts to the divine.
So any or all of the above could make it being a hallucination more likely.
If you have no independent evidence, what someone claims could also just be a lie. Although I wouldn't jump straight to that, as it's more productive and respectful to give people the benefit of the doubt and accept that they believe what they're saying.
When isn't a hallucination the best explanation?
To make the case for when a hallucination wouldn't be the best explanation, one could start by turning all of the above on its head: a non-drug-user sees something clearly in broad daylight, and otherwise has a firm grasp of reality and no relevant illness nor brain injury. That alone probably doesn't really get us to the finish line though.
Beyond the above, the best way to make the case for some other-worldly entity above a hallucination would be to extend beyond a singular experience:
- Shared experiences (although shared delusions may also be a thing)
- Repeated experiences
- Divine healing: this has been reported plenty, but those reports suffer from a lack of well-documented medical verification of the ailment and the healing and/or the ailment could go away by itself. As atheists commonly point out, amputation is something we've never seen go away by itself, and we conveniently also have zero verifiable examples of the divine healing of an amputee.
- Future predictions. One could say a lot about this. But just note that there are some criteria for what makes a good prediction, e.g. being specific about exactly what will happen and when, avoiding any sort of metaphors that could be predicted in multiple ways, and predicting rare events. Of course if someone says "God told me that will happen and it happened", that wouldn't be all that compelling, compared to someone telling you ahead of time what will happen.
- Giving knowledge: If one gains some knowledge that one didn't know before (e.g. scientific discoveries), that may make a hallucination less plausible. Although it might be the case that you merely figured it out during a hallucination, or that you remembered something you've merely forgotten.
Other explanations?
For any competing hypothesis, one also has to consider how well that explains the experience, whether other things could explain it more simply, and how well it aligns with reality generally. Some would consider the problem of evil and divine hiddenness to altogether refute the existence of a deity with a specific combination of traits (all-loving and all-powerful). That pushes the bar much higher for accepting the existence of such a deity. Although one might still accept the existence of some powerful being (deity or not) without those traits.