When the soft tissue in the pulp chamber is infected (has bacteria in it) or affected (is inflamed), it can be removed by a dentist under local anaesthetic.
Afterwards the tooth is restored with a regular filling or a stainless steel crown.