You see it in your day to day life, when something happens that has no explanation we as humans need one, so we often invent one. If someone took a strange action we quite often justify it in our own heads - sometimes with a very convoluted and most likely improbable reason. When our forbearers had no explanation of why the sun rises because they didn't have the tools (nor the prior learning required) to understand it. So they invent a billygoat kicking the sun around the sky creating day and night. Religion is a side-effect of having an imagination and our need to explain the world around us. Literature, art, poetry and music are the good things we get from imagination. Science, engineering and math are the benefits of our need to measure and explain the world around us.
So while your holy text might contain morals (some of which are great, others, i struggle to fit the world "moral" around) the bit about creation come from cavemen/hunter-gatherers that had yet to workout how to work metal or polish optics to build the tools that would have given them evidence to the contrary.