When a tooth is decayed or accidentally fractured and reaches to the sensitive vital part of the tooth, the pulp, it can be risky to just fill and leave.
Risk is that the root canal gets infected which may lead to pus formation below causing swelling, severe pain, fever and over time it can lead to more severe complications like granuloma, cyst or tumor formations.
So basically root can treatment is performed to eliminate future complications. In this, we remove everything inside the canal and fill it with inert materials followed by crown/ capping.
Capping ensures the durability of a tooth since it is dead now after performing the root canal. Sometimes we perform intentional RCT in which a tooth is expected to expose its vital pulp during filling or when a crown preparation is done for the dental bridge. It ensures that after bridge placement the tooth may not become symptomatic else whole bridge has to be removed or we need to perform a difficult RCT from over the crown.