How does praying help a dying person?

Annika • Witch🌜Gamer 🎮 Ravenclaw 💙
This is a legitimate question. Not trying to offend anybody or diss their religion. 
I see a lot of posts on the internet of people asking for prayers for someone that is in the hospital, in critical condition and may not survive. And I don't understand how praying would be helpful? even if you believe in God. 
God already knows about this person being in bad shape (because he is all seeing and all knowing), and he already has everything planned out (according to those who believe in God. He has a plan for everyone.). He has already decided if this person is going to survive or not. So why would praying do anything? How is it helpful?