Where did the fear of the dark come from? Is it religiously influenced? Were we born with the fear of the unknown? Or did we learn to be afraid of what could happen to us in the dark?

I expect it developed as a consequence of what could happen in the dark. Humans are very visually oriented creatures, so we don't work well in the dark. At one time, we were also not at the top of the food chain. Our predators were much more capable of operating in the dark. When being eaten by predators you can't see until they attack you, being afraid of the dark is a reasonable precaution. The dark also makes it much harder to detect venomous snakes and the like.

This is likely also the reason that so many religions have incorporated evil as being more comfortable in the dark. It is a throwback to that primal fear of the unseen predator.

Nowadays of course, our chances of being jumped by a lion or running across a venomous snake is vanishingy slim, but there is always the threat of a human predator jumpng us (this is of course highly variable on where you live). So it makes sense that a fear of the dark is retained. But hopefully we can reason out when and where such fear is warranted.