Thats quite a broad question....
I think it was edward burnett tylor, founder of british social anthropology who had this idea, that religion evolved from dreams. Well, we simply don't have the data to support this claim, so we might as well speculate, that it was a tryptamine dream in which mankind spoke to god for the first time.