A person needs to believe in something to be reassured that everything will be ok. By praying your brain reassures itself, finds strength to go further, it's like spiritual selfmotivation. I think the same happens when you take a placebo - you convince yourself that the pill will fight the disease. And if we are talking about mental health then religion sometimes may become a placebo instead of a pill.