Praying is a form of meditation and free therapy. When you do praying in a community setting I suppose you’re putting your intentions out there in the world. If there is a God or if we’re living in a simulation where ritual makes reality then we are manifesting our own reality. When you do it alone ritually it’s a meditative exercise, especially if it’s the rosary, Our father, or even the “now I lay me down to sleep” prayer. If it’s a routine you do it’s no different than other mindfulness exercises. Repetition is calming, and can be a signal to your brain. If you’re doing non-standard ritual prayer, like something adhoc then you’re having an inner monologue with somebody (whether real or not). So you’re expressing your fears, wants, thankfulness, and problems, and working through your issues with somebody you feel is a loving friend who presumably wants the best for you (if you’re religious). Here’s an article that talks about the physical benefits: https://www.nbcnews.com/better/amp/ncna812376