Go through this article if you want to know the answer!
Most kids go through a stage in which they're afraid of the dark. Any creaking floorboard, rustling shutter, or random bump in the night fill them with terror. Good! Here's why, and why we should maybe never grow out of it.
It's maybe an obvious point, but it's not the dark itself that children find so terrifying, it's the fear of whatever boogeyman or the supine monster under the bed that made the sound, to begin with. This fear, and the grinding anxiety that it generates, acts as a check and limiting mechanism against reckless behavior like, say, running around in the dead of the African night with a continents-worth of big cats out on the prowl. In other words, it's an evolutionary advantage.
Remember, for a large portion of humanity's early days, we were far from the top of the food chain. Our ancestors quickly learned that many predators prefer the cover of darkness to hunt and over time that association strengthened into a subconscious absolute: stay out of the dark because that's where the danger is.
While fear of the dark can manifest itself as an acute reaction—like panicked screaming when someone suddenly turns out the lights, or as insomnia, as a recent study conducted at the University of Toronto suggests—it more commonly manifests as foreboding anxiety. The emotion of anxiety plays a specific role in our behavioral responses to stimuli just as the emotions of love, anger, and sadness do, acting to increase our ability to cope with stress and more fully exploit beneficial opportunities.