Why do hallucinations appear in depression?
Have a look at The God drug DMT. It causes people to see/talk to God and can be taken as an actual drug, but I believe it is also produced in the body during near death experiences. I am no expert in it but here's wikipedia: https://en.m.wikipedia.org/wiki/N,N-Dimethyltryptamine