You see, what I just don't get is how prayer can possibly change the mind of an all-knowing, infinitely wise, all-powerful, omni-benevolent god who has defined right and wrong for us and knows our deepest, most secret thoughts.
Such a god would have ensured only the best for its creation and would have set this in motion right from the start, so the purpose of prayer can't possibly to persuade such a god to change its mind.
Such a god would know everything that is happening, so the purpose of prayer can't possibly be to inform it about some impending disaster or to ask it to prevent one from happening. Nor can it be to inform it that someone needs help to overcome some difficulty or recover from an illness.
Such a god will already be aware that something happening, or which is about to happen, is wrong, so prayer can't possibly to help it tell right from wrong.
Such a god would already know whether the person praying is truly sorry for having done something wrong, or having failed to do something right, so the purpose of prayer can't be to let it know or to fool it into thinking the person is sorry when they are not.
Such a god would know whether the person praying really loves it or not, so the purpose of prayer can't possibly be to tell it the person loves it or to fool it into thinking the person does when they don't really.
Such a god would already have decided whether to let a sick child live or die, or a baby to be conceived, or a famine, drought, epidemic or war to continue or end, so the purpose can't be to persuade it to change its mind.
And such a god would already be aware that a person is thankful for something or not, so the purpose of prayer can't be to inform it of that or to fool it into thinking they thankful when they are not.
And, of course, an omni-benevolent god would already have forgiven someone who deserved to be forgiven so the purpose of prayer can't be to persuade it to forgive or to trick it into forgiving someone unworthy or forgiveness.
So, the purpose of prayer must be something not connected with the god in question. The purpose of prayer must be for the benefit of the person praying or the purpose of the person cajoling them to pray.
The purpose of prayer can't be to help someone else. To help someone else you need to do more than make useless noises at an imaginary friend, even if that might earn you kudos for your piety amongst your fellow worshippers in the Church of Piety and Empty Gestures.
So, can anyone come up with a convincing purpose for prayer, other than self affirmation and a public display of piety?