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 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 behaviour like, say, running around in the dead of the African night with a continent's-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 behavioural 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.
As Isaac M. Marks and Randolph M. Nesse stipulate in Fear and Fitness: An Evolutionary Analysis of Anxiety Disorders:
Each emotion can be thought of as a computer program designed to accomplish some specific fitness task particularly well (Nesse 1990). If the current task is courtship, romantic love is helpful. If one is being betrayed, anger is useful. If a tiger is attacking, then fearful flight and avoidance are best. If people are disapproving, then social anxiety may be appropriate. Different emotions, however, must be orchestrated, just as endocrine function must be coordinated in an endocrine orchestra. Emotional responses must fit changing adaptive challenges, with each emotion fitting a particular kind of situation.
Specifically, anxiety increases your awareness of situations that may damage your reproductive resources. Not just your vital signs, but your relationships, income, social standing, physical features; anything that makes you more attractive to the opposite sex and more likely to reproduce.
Unlike anger or sadness, which occur in direct response to a specific event, we respond to environmental cues indicating a potential future loss with anxiety prior to the expected event, since that's when it is most evolutionarily beneficial. That is, our ancestors who best recognised and responded to these cues increased their chances of survival and reproduction compared to their more mutton-headed peers. Feeling anxiety over a past event is a complete waste of your resources since whatever damage has likely already been inflicted. Not only is it no use crying over spilled milk, doing so could get you killed (if you're a Neanderthal).
Since that response is correlated with natural selection, certain cues -- such as snake- or cat-eye patterns, spider-like objects, and darkness (where the snakes, leopards, and spiders all live) -- more easily invoke that emotion. This is the result of generation upon generation of early humans reacting to and subsequently preparing for dangers such as these. That's why many ancient threats -- uncontrolled fire, spiders, snakes, predators, and darkness -- are more easily instigate a negative response, even in small children, than modern threats like automobiles, nuclear war, or guns do.
While anxiety is deeply rooted in our psyche, it is not entirely instinctive. We also learn fear and anxiety responses from our parents. If a small child is frightened of an new or unknown object and its mother responds in a calming manner, the kid learns that the item is not a threat. If the parent responds with apprehension herself, however, the child's fears are confirmed and enhanced. This allows for offspring to rapidly learn of the dangers around themselves without actually having to be bitten by snakes, mauled by lions, or be electrocuted by a penny in the wall socket while simultaneously figuring out that everything from leaves and small rocks to thunder and scary scenes on TV aren't actual threats.
It's quite a beautiful system, really. This subtle gnawing emotion has been honed and refined over millennia by both nature and nurture into a vital survival response that remains as useful in the modern world as it did in the Neolithic. Sure, the environmental cues have adapted somewhat, with anxiety over social interactions and property replacing those over finding shelter and not starving to death, but the basic threat response remains: Make sure you get yours live to reproduce another day. The fear of the dark, and by extension the fear of the unknown, are simply there to make sure you don't ever forget it. [Indiana University - Time - HuffPo - Wiki - University of Michigan]