Filling a tooth is necessary when there is a deficit in its structure. The cavity damages not just the one tooth, but it can spread and damage the neighbouring teeth too.
The lack of tooth structure can be a result of physical impact (abrasion, cracking, etc.) or chemical effect (dental decay). The enamel of the teeth becomes vulnerable and permeable which causes the dentin (one of the hard tissues of the tooth) to outcrop to some extent resulting in sensitivity, pain or inflammation. It isn't just the sensitivity that may cause problems, the bacteria that reaches the dentin can also bring on complications, so filling the affected teeth is inevitable.