If there is any dogma that sticks in the craw of non-Catholics, it is that of papal infallibility. "How can Catholics actually believe that any human being be incapable of error?" ask many observers.
But what about the human authors of sacred Scripture? The Gospel narratives are quite frank about the foibles of Peter, Paul and the rest. But all Christians believe that their writings come not from them, but were inspired by the Holy Spirit. In all that they teach us about God and his plan for our salvation, they are therefore "inerrant."
The pope and bishops of the Catholic Church are no less human than the apostles and evangelists. Left to themselves, they can make their share of mistakes. But in their capacity as apostolic teachers, they are not left to themselves. They receive divine assistance much like Peter received at Caesarea Philippi when he blurted out that Jesus was the Christ, the Son of God (see Mt 16:16-17).
So, the Church believes that when the bishops of the world, in the course of their ordinary teaching and preaching, together present a doctrine to God's people as something revealed by God, they teach this dogma infallibly by virtue of the ordinary, universal magisterium.
But sometimes it is hard to precisely identify what all bishops of the world agree upon in their daily teaching. So, when serious doctrinal disputes arose in the early Church, councils of bishops gathered to settle things. These special councils were called "ecumenical" from the Greek word for "household."
They dealt with matters pertaining to the whole household of the faith and represented all the bishops of the world. Hence their judgments, once confirmed by the pope, were considered binding on the whole Christian family.
Some of their pronouncements had to do with discipline, and so they are not binding on all generations. Some of their teaching was doctrinal, pertaining to faith and morals, but was presented in an ordinary way. But sometimes the council fathers engaged the fullness of their apostolic authority and issued solemn dogmatic definitions in which they fundamentally guarantee that a certain truth is revealed by God. They usually make crystal clear their intent to define a dogma by strongly condemning contradictory teachings and noting that those who hold such heretical opinions have put themselves outside the Church.
From about the ninth century, we can document a widespread belief that dogmatic decrees by ecumenical councils are infallible in light of the assistance given to the council fathers by the Holy Spirit (see Acts 15:28).
But what if a council could not be called in time to respond to a crisis? Would it remain up for grabs how we should interpret the Scriptures and identify the authentic apostolic Tradition?
Medieval theologians said no. They saw the special assistance given to Peter by the Spirit in Chapter 16 of Matthew. They noted the extraordinary track record of the popes of the first millennium in upholding orthodoxy even when many of the great bishops and patriarchs from around the world fell into heresy.
Many concluded that the successor of Peter is assisted by the Holy Spirit in a particular way. If he should teach ex cathedra (literally "from the chair" of Peter), engaging the fullness of his apostolic teaching authority on a matter pertaining to faith and morals, his judgment is indeed infallible. From about the 12th century this became a widespread opinion and was defined as dogma by the First Vatican Council in 1870.
Infallibility, then, is not a burden, but a necessary gift, indeed a charism of the Holy Spirit. Without it, the promise made by Christ at Caesarea Philippi could not be kept. Remember, he guaranteed that the jaws of death would not prevail against his Church. But if the Church had no sure way to locate the truth, the jaws of death would be free to gobble up many and shatter the remaining flock into a million pieces.