When does the dentist pull someone’s tooth out?

I am just curious because I have been in pain have a cavity at least one maybe 2 or 3... I have pain bottom right and top right when I bite down they both hurt and I think one is infected, I really don’t want them to pull a tooth out but I don’t know the reason they do it or when, but my gums are fine..
4 answers 4