Cavities generally develop in the "hard-to-see" places in your mouth. These are normally the places where you need to floss. When bacteria combine with food particles, they form plaque that adheres to your teeth.
As long as plaque remains on the tooth, acid produced by bacteria will eat away the tooth structure. Once through the enamel, the acid attacks the dentin, which is that part of the tooth containing sensitive nerve fibers.
If the tooth decay reaches the dentin, a filling is needed to halt the degenerative process. Otherwise, it continues at an accelerated rate becoming larger and larger.
If not detected and repaired with a filling, the decay can reach the tooth nerve and cause the need for a root canal. With the decay removed and a filling in place the tooth is restored to its original contour.