Dentin matrix protein 1 (DMP1) is expressed in both pulp and odontoblast cells and deletion of the Dmp1 gene leads to defects in odontogenesis and mineralization.
Just below that tough outer layer, there's another layer called dentin that's not as hard. And below that, there's the inner layer of the tooth, called the pulp, which has blood vessels and nerves inside it.
That's the stage when individuals usually experience pain, although pain can also occur when the caries lesion involves the dentin layer since sensory nerve fibers travel through tubules in the dentin.
Teeth manage both by having two layers: a hard external cap of enamel, made up almost entirely of a calcium phosphate, and beneath it, a tougher layer of dentin, partly formed from organic fibers that make it flexible.