There are two trains of thought being given consideration. Neither will give definitive answers but they will direct you to questions you can find the answers to.
Firstly, as pack animals there is always a pecking order. Alpha males etc. The movement is dependent on food sources. As herbivores mainly man would go to where crops that were edible, trial and error, popped up, ironically, seeds deposited by faces would follow them like a trail, a natural dispersion of food groups.
A necessity would force intrigue in moving to meat, watching other animals who would naturally be meat eaters and curiosity would make them follow suit.
There is a brilliant theory on the carnivore angle, that when cooked meat was added to the diet, again by accident, finding a carcass in some embers, that the chemical change in the proteins developed the side of the brain that hadn't been developed by habit and habitat, this lead to creative thinking and the development of the Neanderthal mind in a creative way, using natural substances, berries etc, to create 'paintings' in caves was a kickstart to 'kingship/priesthood' as the wonder captured the developing mind.
Added to this was the apparent superiority of hunters to feed groups, one man could kill an antelope that would feed an extended family, that family would look after and revere this hunter into an elevated status.
As hunters/men in general went hunting, women stayed at home with family, young and old, and began to cultivate seeds, planting and tending crops, crops that were now stable in growth meaning the nomadic element was decreased. The extension from that was bigger groups staying in one place, and visitors if they could be beneficial would join. The higher member then had a greater number to 'rule' over. From there came small towns onwards to city states eventually.
When the going was good and people prospered the chiefs, leaders were mourned on death and a cult of ancestor worship developed, relics such as bones were buried and 'monuments' set up to pay tribute. These were the first totems, forerunners of churches, alters etc were sacrifices were made that lead to death cults where leaders of other similar tribes, through territoriality, were captured and their powers absorbed oncde captured and killed...war became the norm, through greed or famine, drought etc.
These were then first 'gods' and snidey members saw the power and authority and developed the worship of ancestors into legendary god status, keeping the people in check as a result, the power becoming self serving.
Secondly, as a consequence, these legends became attached to the movements of the stars and planets, and we're still talking of developments over thousands of years here, 'priests' of the stars would study precession etc and as the timescale of movement was slow could predict 'events' and make themselves 'magical' to the ordinary tribes people.
The other aspect is intervention and teaching, but even incorporating this into the above is down to some travelling elsewhere and taking their knowledge to an unwitting and underdeveloped tribe or peoples, in the carrying a mobile far into the amazon way today.
As I said this doesn't give any answers, but to reference stuff, find Uriel's machine which deals with a knowledgeable peoples, the grooved ware people, moving into northern Europe and to this country via Scandinavia, telling their tales and sagas and sharing their knowledge wherever they went. The megalithic yard is a great enabler to understanding all this too.
Have fun...