I preface this writeup by noting that I come to it from a somewhat skeptical point of view when it comes to this doctrine, although I think there is a lot of good truth nestled behind it (perhaps even being obscured by it. But that's another node.)
There is some dispute over the history of this doctrine as it is currently understood; while some would have you believe that current dogma dates back, unaltered, to the first century, history says otherwise.
The doctrine was first codified outright in Vatican Council I in 1870; it was actually one of a pair of related tenets:
- The infallibility of the pope when speaking ex cathedra in matters of faith and morals (and it doesn't take much of a creative argument to make just about everything a faith/moral issue; in this sense, the boundaries of this argument are elastic)
- The primacy of papal jurisdiction, that is, the pope has plenary authority ("direct sovereignty") over the entire church, at any time, in any situation.
Some bishops and cardinals contended that these two, taken together, reduced the entire ecclesiastical government to lackeys of the Pope; even if the ex cathedra authority is exercised only with great care, and even given the ability of the church to employ dialectic retroactively to say "he wasn't really speaking ex cathedra; that doctrine is malleable", the very tenor of these doctrines elevated the popular perception of who and what the pope really is in ways that were detached from the historic tradition of the Roman Catholic Church.
A brief overview of the history leading up to VC1:
While there are historic texts that hint at strong ecclesiastic authority dating back to the 3rd century (and debatably the 1st), hints that this extends directly and personally to the pontiff are generally lacking until around the 7th century, and the scriptural arguments to the infallibility of a single human office are problematic at best and red herrings at worst.
Hasler's history indicates that infallibility was first identified and ascribed to the Pope outright by a Franciscan priest in 1279.
Interstingly, Pope John XXII attributed the very notion that his office bore a mantle of infallibility to the devil in 1324.
There was some rise in the doctrine's popularity during the protestant reformation, perhaps because nothing shuts up argument quite like unassailable authority.
The first pope to personally own and wield infallibility was Pope Gregory XVI (1831-1846). His successor, Pope Pius IX, is credited with elevating the doctrine to it's current status as dogma. He is also credited with the rise of papolatry; one title popularly ascribed to him was "vice-God of humanity". Protestants are particularly fond of ol' Pius for also making an (infallible) dogma of the Immaculate Conception of Mary, a position difficult to argue (at least as far as I can tell) from scripture.
Naturally, this opens up the problem of the openness or closure of the canon; if the Pope can speak ex cathedra to clarify interpretive matters and ex scriptura derived doctrines, that is one thing; if he can introduce concepts like this ex nihilo, and do so infallibly with the full authority of the church, well, that's a horse of a different color. How is it qualitatively different from adding to scripture?
A. B. Hasler, "How the Pope Became Infallible", Doubleday, 1981
for facts, framing, and organization used in this writeup.