Researchers showed a group of children an empty box and then told them not to touch it because there was a fox in it.
New children were introduced into the room.
They were warned by the original occupants not to touch the box because now there was a fox in the box.
That should tell you all you need to know about the origin of religion.
but it does not tell us why in the first place someone says to humans there was fox in box. or there is god in universe.
i believe someone did it because s/he was afraid of death and wanted to live forever. and wanted solace. and was stupid and not knowledgeable.