Here’s my view on this. My theory is that morality comes from human interactions. We see what works and what doesn’t, in terms of our goals. We find that we are better able to survive if we treat each other as we want to be treated then if we steal and try to “get over” on others. It is something that I think game theorists believe would come up in any society. I believe it, anyway.
Now what is God’s role in this? Think of morality as something that is learned. As with much learning, you have to do some persuading in order to get people to buy into the moral system. Sometimes we don’t have time or the will to let our children learn this stuff on their own. Sometimes we can’t wait for people to figure it out (if they didn’t figure it out as children).
In a patriarchal society (and most are), it is standard to have a leader who tells people the rules and they better follow them, or else. It seems efficient. No one has to think. You just have to do what the leader says and everyone is ok.
Some religions use God this way. God is the leader of leaders, and if you don’t do what He says, you’ll lose all rights to be in this society. Of course, God says what his priests say He says. This was especially true in times when priests were the only ones who were educated and who could read. Knowledge is power, and the religious folks were the only ones with a lot of knowledge.
So, to keep folks in line, they created a mythology around the idea of a Deity. These stories were used to illustrate the power of God, and they bought the legitimacy the priests needed to tell people to do what they said.
God, then, has a civilizing function. He is a tool in the process of pacifying society. He doesn’t always work, of course. Then you have to figure out how to get people who break the rules to feel like they can come back into society without being killed. And thus you get a separation of church and state. God loves the sinner, and the state kills the sinner, to put it crudely.
This isn’t the case with only the Christian God, either. All religions provide ways of passing knowledge on. Gods are pedagogical tools, as are ritual and music and dogma. It’s all in aid of teaching people something they would figure out anyway, if they thought about it very much. But by using a God to pass on information, you don’t have to convince anyone that something makes sense, you can get them to accept it because the Deity said it was so.
It’s efficient and it worked in past times, but now education is much more universal. People think for themselves much more. A didactic deity is no longer appropriate. Yet so many religions try to keep that deity in place. Others are more willing to change with the times, and their deities take on different roles, since they are no longer needed to convince people of what is right and true.
There is, of course, a whole lot more I could say about just about every aspect of this, but I will leave it here. God helps in the process of teaching people about what works to hold society together. This worked well in a time when hardly anyone was educated. Now that most people are educated, it isn’t working well, and that is one of the reasons why so many people have become atheists.