Or maybe the Bible and Gilgamesh comes from the need to pass on important lessons and facts to the next chunk of humans i.e. this is why it's important to learn how to make boats, sometimes climate changes and you need a backup plan, don't eat pork because God says so -- and also because if not properly cooked you'll get trichinosis (they didn't know this but throwing a label of pork = evil is good enough). If you read the bible at face value it has pretty basic rules of society.
> Some people came to the chief with a conflict. He went into a special tent, "communed with the storm-god", and came out with some new rules for how to manage a tribe of herders that has grown beyond Dunbar's number.
Repeat that, mix in an origin story, some king lists, and tribal-unification propaganda and (modulo some path dependency) you'll have a book that people will be treating as the literal truth 2500 years later.
Yuval Noah Harari in "Sapiens" has an interesting take on religion. Essentially they form a fictional narrative that deigns this and that. In doing so they create a system which can thread together far larger groups of people, we're thought to be near maximum capacity in dealing with 150 people (according to Dunabr's number). But the fictional narratives of religion (and later government, laws, corporations...) help us to identify our personal relationships, and also help us to ascertain expected behavior, both of self and of other. Thus we can drastically expand interoperability between individuals and groups. This is of course entirely contingent on belief, which basically serves the argument issued in "The Social Contract". He defines this as inter-subjectivity.
> If you read the bible at face value it has pretty basic rules of society.
Specifically, the portion of the Ten Commandments which instructs how to relate to other people (as opposed to relating to God) is just as relevant today as it was when written.
> Specifically, the portion of the Ten Commandments which instructs how to relate to other people (as opposed to relating to God) is just as relevant today as it was when written.
Sure, but the parts of the rest of the exodus narrative (either in Exodus or Deuteronomy, the two places the Ten Commandments appear) that discuss dealing with other people are...less so.