Every scientific theory has some counter-examples or "discrepancies".
But, in general, a "good" theory will not be rejected until a "better" new theory is available.
"Little" discrepancies, like that involving Mercury's orbit were far less relevant that "big" successes like the correct prediction of the existence of a previously unseen planet; see Discovery of Neptune (1846).
You have to take into account that, also after the availability of a new "better" theory, like Relativity, that is able to explain Mercury's orbital anomalies, Newtonian' mechanics is so "reliable" (being an approximation of Relativity that fit very well when the velocities involved are very little when compared to the speed of light) that human being have been able to safely "land" on the Moon (mission: Apollo 11 : July 20, 1969) and come back based on calculation that are not so different in principle from what Newton himself had done in his masterpiece of 1687: Philosophiae Naturalis Principia Mathematica.
Scientifc knowledge is not "perfect": we have to continue to revise and improve it.
So, good luck for your student career: we need future scientists that can contribute to the process of continuously improvement of human knowledge.
Note : suggestion for your future studies in depth :