A new study suggests that the formation of complex societies came first and that the beliefs in such gods helped unite people under a common higher power. There are some misunderstanding about this study published in NATURE
There is a theory that those Big Gods were necessary for humans to achieve this level of societal complexity. The new study provides some evidence against this "Big God" Theory.
BUT: It is not true that small-scale societies like those of hunter-gatherers have no religion or no belief in supernatural beings. Of course they had and still have (where this kind of society has survived).
And even morality was part of the picture: the spirits of ancestors had the same demands as a living human beings, and they punish if their demands and wills are not met or satisfied. That is the reason why people in small-scale societies make sacrifices, or why they have experts like shamans who can act as mediators between the world beyond and the world people are living in.
Just think of Göbekli Tepe, where hunter-gatherers built a huge temple complex long before any society came near the 1 million threshold. Claiming that these people did not have religion would be ridiculous. Their religion was just different from the kind we see in the Bible
The question is: When did big moralistic gods enter the scene?. The new evidence suggests that the spirits became Gods after societies crossed a certain threshold.
That does not mean that religion was invented after humans had constructed states or cities. The existing supernatural beings just morphed into something bigger in order to help stabilize those big societies.
(see: [livescience.com]