Once upon a time, hundreds of years ago, there existed a species called homo sapiens. They had an enormous amount of processing power, an excellent ability to match patterns, and a level of consciousness and self awareness that had never existed before.
They understood many of the things they saw in the world, but others were mysteries. It wasn't that they couldn't process what was around them, but rather that they hadn't developed the context for it. Seeing giant bolts of lightning strike down from the sky must have been terrifying. Nothing in their experience could begin to explain such a thing.
If we can simplify a bit and say that scientists' jobs are to figure out all of the causes and effects, it could be said that we've always been scientists, albeit bad ones. Cave men started noticing correlations and assigned meaning to them. Maybe they saw a white bird, and the next day it rained. How could they know that the white bird didn't cause that rain?
Some phenomena didn't seem to have direct causes, or maybe sometimes the correlations spotted didn't line up anymore. It rained, but no one in the tribe saw a white bird. Searching for meaning, our ancestors imagined supernatural beings, and nonsense was born.