A recent study concludes that loneliness increases belief in supernatural agents. While some of the study protocols are a bit questionable (the results were from groups attempting to empathize with lonely characters in films, rather than actual lonely people), the results shouldn't seem too surprising to us nonbelievers. Lonely children invent imaginary friends all the time, why shouldn't lonely adults do so as well? The difference is that the poor adults lack the imaginative power of children, so they use existing characters rather than creating new ones.
This is also why studies touting god beliefs because religious beliefs were found to correlate with good mental health miss the point. Of course a lonely person is going to feel better believing in a god than not, just like the children with imaginary friends do. That doesn't imply those things exist. This is also tangentally related to why the majro religions promote social rules that almost universally deny pleasures. People who are happy and content on their own have little use for demanding magic men.