Sometimes the only way to save a badly damaged tooth is to eliminate the infection within the tooth via endodontic (root canal) treatment.  With your tooth properly anesthetized, the process should be painless.  The long term prognosis for most teeth with root canal treatment is very good, though not 100%.