Technically, snakes do not hear because they don't have ears. Specifically, they are deaf to sounds that travel through the air. However, they do manage to sense what would be sounds to animals with ears. However, the snake does have an inner ear.
Sound waves strike the snake's skin, pass through the muscles, and then to the bone that attaches the inner ear to the skull. The part of the snake's body that makes contact with the ground also feels vibrations keenly, especially the bones of the jaw. These vibrations are passed on to the cochlea, an organ in the inner ear that is shared by both snakes, other reptiles and humans. Hairs in the cochlea pick up these vibrations. The animal's brain then processes footfalls or the movement of potential prey or predators.
Some biologists believe that the snake's lack of an external ear is the result of their ancestors' habit of burrowing. These ancestors were lizards. It's believed that the ears were lost to remove the risk of them filling up with soil and also because the animal couldn't hear airborne sounds underground anyway.
Other scientists believe that snakes evolved from mosasaurs that lived in the seas. Mosasaurs lost their hearing because external ears were useless under water.