I was thinking about something on a similar train of thought as this recently. Not exactly, but similar.
I was thinking about Thomas Hobbs, who was this philosopher who basically believed that humans, when left to their own devices, are a-holes. Or in other words, that people are selfish and always look out for themselves first, and what is best for their continued survival at optimal conditions. And a solution to that was to have a social contract of sorts, and a Leviathan.
So if I agree not to kill you, and you agree not to kill me, than we can both focus on growing a garden instead of sharpening tools to protect ourselves from one another. That's the contract bit. Then there is the need for an enforcer, or a leviathan, to make sure people adhere to the contract. In modern day first world countries, it's the government that takes this role. If I break the contract and kill you, the government will punish me.
It's still people looking out for their best interests though. Adhering to the contract and others doing so as well would in theory allow for me to live the best possible life, and for others to do the same.
So I was applying this to religion and two thoughts came to my head. One was what you were getting at Blue, in that it was man-made to function as a leviathan itself. Sort of as a "Hey! Don't murder people or you will spend eternity burning in hell! Isn't that much less in your best interest than, oh, I don't know, just not killing people?" So if that was the reality, that seemed to make sense to me.
On the other side, in argument for God's existence, and if the world is full of a-holes as Thomas Hobbs suggests, what's the dude supposed to do to stop people from acting like a-holes? I mean he could come down and be like "yo guys, it would be really awesome if y'all were nice to each other, and really it would be beneficial if you didn't have to sleep with one eye open, amirite?" but without any muscle to back it up, you're going to have plenty of people seeing the opportunity to take advantage of this system. If that were the case, it would also make sense for the reward and punishment system to exist as it does.
I don't really know though, those were just thoughts that popped in my head though. I've always struggled with the seemingly infinite number of unknown variables when discussing the topic. It's interesting to look at through a particular lens once and a while though.