Dentists frequently prescribe antibiotics before and after endodontic treatment for reduced chance of systemic infection, reduced pain, increased success rates, and a variety of other reasons.
Your dentist may put you on antibiotics that shrink the infection, which would also cause pain to subside.
The antibiotics will help your body fight off the infection, making the anesthetics used prior to the root canal more effective and also reducing your pain in the days leading up to the treatment.
Although antibiotics can help keep the infection from spreading, the only way to remove the infection completely is by performing root canal treatment and cleaning out all the dead tissue and bacteria inside the pulp chamber and root canals.