The doctrine of papal infallibility is not founded on biblical texts specifically. It is founded on the "biblically supported" doctrine that the church is the custodian of truth. What is the scriptural support for the Catholic church's claim that they are the custodians of truth? What does it mean to be the custodian of truth. Does this mean that they believe in modern revelation and receive direction from God?
Let me begin with the second question, which is simpler. The Catholic Church does not believe in modern revelation. The Catechism of the Catholic Church says
66 "The Christian economy, therefore, since it is the new and definitive Covenant, will never pass away; and no new public revelation is to be expected before the glorious manifestation of our Lord Jesus Christ" [Vatican Council II, Dei Verbum 4]. Yet even if Revelation is already complete, it has not been made completely explicit; it remains for Christian faith gradually to grasp its full significance over the course of the centuries.
So, there is no new revelation—for Jesus Christ was the definitive Revelation—but our understanding of that revelation can increase over time. This (the Church feels) is what Jesus means when he says
These things I have spoken to you while I am still with you. But the Helper, the Holy Spirit, whom the Father will send in my name, he will teach you all things and bring to your remembrance all that I have said to you (Jn. 14:25-26).
We see on many occasions in the Scriptures that the disciples do not understand what Jesus is teaching them until after the Resurrection; this same process (the Church holds) has continued through the centuries. We see it, for example, in the development of the dogmas on the Holy Trinity, which are not explicit in the Bible (but not false or forced interpretations of the Scriptures either).
Returning to the original question, one Biblical argument comes from St. Paul. In his first epistle to Timothy, he writes in order to instruct Timothy so that he
may know how one ought to behave in the household of God, which is the church of the living God, a pillar and buttress of the truth (1 Tim. 3:15).
It may come as a surprise that the pillar and buttress (στῦλος καὶ ἑδραίωμα) of the truth is not the Scriptures, or Christ, but the church. (The "church" here is the assembly of the faithful; whether this church can be identified with the Catholic Church is a different question.) This suggests that the church, the assembly of the faithful, when it reaches a consensus in faith, can actually be a criterion ("base" or "buttress") of the truth; moreover, it suggests that revealed truth is always arrived at in the assembly, seldom individually or independently.
Jesus promises to send the same Paraclete (Helper) that is spoken of in John 14:26, the Spirit of Truth:
And I will ask the Father, and he will give you another Helper, to be with you forever, even the Spirit of truth (Jn 14:16-17).
Combining this with Jn 14:26 suggests that the apostles have a special role in teaching the things that Jesus has taught them, under the guidance of the Holy Spirit. This is indeed the command given by Jesus at the end of Matthew 28:
Go therefore and make disciples of all nations, baptizing them in the name of the Father and of the Son and of the Holy Spirit, teaching them to observe all that I have commanded you. And behold, I am with you always, to the end of the age (Mt 28:19-20).
Finally, it seems that Peter has a special teaching role even among the apostles:
Simon, Simon, behold, Satan demanded to have you [ὑμᾶς, plural], that he might sift you [ὑμᾶς] like wheat, but I have prayed for you [σοῦ, singular] that your [σου] faith may not fail. And when you [σύ] have turned again, strengthen [στήρισον, singluar] your brothers (Lk 22:31-32).
We know that a prayer by the Lord cannot possibly fail. This suggests that Peter has a special protection for his faith, and that by it the other apostles gain strength.
We could say, in summary, that the passages in the scriptures mentioned above suggest three ideas:
- The custodian of revealed truth is not the individual believer, but the assembly of believers (the church) (1 Tim. 3:15).
- The apostles have the special obligation to teach what Jesus revealed to them and they receive assistance from the Holy Spirit to do so. This assistance will last "to the end of the age" (Jn. 14 and Mt. 28).
- Peter has a special task of strengthening his brethren. He is assisted in this by Jesus' prayer that his faith will not fail (Lk 22).
The key Biblical passage is Mt 16:18: "And I tell you, you are Peter, and on this rock I will build my church, and the gates of Hades will not prevail against it" (NRSVCE). Though such a citation inevitably hearkens back to certain meta-questions about the use of "πέτρᾳ," the Catholic Church has always seen it as referring to the specific ministry of Peter, out of which grew the institution of the Papacy.
It would follow as a corollary that this "not prevailing" depends not on any human strength but on a special kind of assistance: hence the "parakletos" referred to most insistently in Christ's Last Supper Discourse.
Important to note (though perhaps a bit ancillary to this particular question) is that a Catholic would take issue with one notion that seems to underlie your question, that a doctrine is valid only insofar as it is "founded" on or directly corroborated by Scripture. Though Scripture is an extremely important "fons revelationis"--and some theologians would be willing to argue that all doctrine can be implicitly found in it--the Catholic Church has always had strong confidence in the value of Sacred Tradition (capital "T"), built on the practice of the Apostles and the teachings of the early Church.
As for the precise meaning of "custodian of the truth": the Catholic Church speaks of a "depositum fidei" (deposit of faith) closed at the death of St. John, which constitutes the public revelation of Christ, in whom all the truths of salvation are contained. Though further revelations ("private revelations") are not rejected, and sometimes are approved as useful (such as the apparitions at Fatima and Lourdes), they belong to a separate category altogether because they are directed at understanding the "depositum" in a more profound or culturally focused way. Catholic dogma all exists in the "depositum," though centuries of development and interpretation prompt us to see things that were not clear before, such as the Assumption or Immaculate Conception. No "modern revelation" that purports to add something to the deposit of faith is admitted by the Church.
The proper relation of Scripture, Tradition, and the Magisterium is expressed well in Dei Verbum, the Dogmatic Constitution on Divine Revelation. Cf. especially #10:
Sacred tradition and Sacred Scripture form one sacred deposit of the word of God, committed to the Church. Holding fast to this deposit the entire holy people united with their shepherds remain always steadfast in the teaching of the Apostles, in the common life, in the breaking of the bread and in prayers (see Acts 2, 42, Greek text), so that holding to, practicing and professing the heritage of the faith, it becomes on the part of the bishops and faithful a single common effort. (7)
But the task of authentically interpreting the word of God, whether written or handed on, (8) has been entrusted exclusively to the living teaching office of the Church, (9) whose authority is exercised in the name of Jesus Christ. This teaching office is not above the word of God, but serves it, teaching only what has been handed on, listening to it devoutly, guarding it scrupulously and explaining it faithfully in accord with a divine commission and with the help of the Holy Spirit, it draws from this one deposit of faith everything which it presents for belief as divinely revealed.
It is clear, therefore, that sacred tradition, Sacred Scripture and the teaching authority of the Church, in accord with God's most wise design, are so linked and joined together that one cannot stand without the others, and that all together and each in its own way under the action of the one Holy Spirit contribute effectively to the salvation of souls. Source: Dogmatic Constitution on Divine Revelation Dei Verbum Solemnly Promulgated by His Holiness Pope Bl. Paul VI, November 18, 1965.