Pretend for a moment a Pope is infallible not only in matters of faith or morals, but in trigonometry. He is presented with an examination consisting of one hundred trigonometry problems. What is the least number of problems he will answer correctly?
Someone who says “one hundred” may understand trigonometry, but his understanding of infallibility is no better than the average non-Catholic’s. The correct answer is: zero. Although infallible in trigonometry, the Pope might get none of the problems right. Being infallible in trigonometry would mean being prevented from putting down the wrong answers. It would not mean being able to put down the right ones. The answer sheet could be left entirely —and would be, if the Pope had not done his homework.
It is the same in real life. Through the guardianship of the Holy Spirit, the Pope is guaranteed not to teach error regarding faith or morals (presuming, of course, he intends to make an ex cathedra statement and is not speaking as a private scholar). But he cannot teach what is true unless he first knows what is true, and he learns that the same way we do.
The inability of the Church to teach error is infallibility, and it is a negative protection. It means what is officially taught will not be wrong, not that the official teachers will have the wits about them to stand up and teach what is right when it needs to be taught.
The Holy Spirit prevents a Pope from officially teaching error, and this charism follows, necessarily, from the existence of the Church itself. If the Church is to do what Christ said it would—and not do what he said it would not do, such as have the gates of hell prevail against it—then it must be able to teach infallibly. It must prove itself to be a perfectly steady guide in matters pertaining to salvation. There is no guarantee that any particular Pope will not let slip by chances to teach the truth, or that he will be sinless, or that mere disciplinary decisions will be intelligently made. It would be convenient if he were omniscient or impeccable, but his not being so will not subvert the Church. But he must be able to teach rightly, for that is the main function of the Church. For men to be saved, they must know what is to be believed. They must have a perfectly steady rock to build on when it comes to official teaching, and that is why papal infallibility exists.
—from Catholicism and Fundamentalism by Karl Keating, Ch. 18: Infallibility of the Pope