Whiskers are not just normal hairs, they are connected to the nervous system and act like a human hand groping around in the darkness. Just like a human feeling an object with their fingers, mammals move their whiskers back and forth to figure out the shape and texture of objects in their path.
The arrangement of the whiskers corresponds to the arrangement of the nerve endings in the brain, so each whisker has its own area of the brain. This makes whisker detection extremely fine-tuned and helps whiskered mammals see in pitch darkness.
Image from flickr.com/photos/ekilby