The theological basis of the belief, in its simplest form, is that as God is infallible, the Bible, as the Word of God, must also be free from error. A more nuanced restatement of the same idea is that God inspired the authors of the Bible without marginalizing their personal concerns or personalities, and so preserved the texts from error.
Protestant churches, unlike Eastern and Roman churches, reject that there is an infallible authoritative tradition that is held over Scripture. Some Protestants hold that the Bible confirms its own infallibility, pointing out that Jesus frequently quotes Scripture as if it was meant to be taken historically rather than entirely allegorically, and citing John 10:35 "the Scripture cannot be broken," they conclude that if the Bible is not inerrant, then Jesus is a liar.
Roman Catholic teaching holds that the resurrection of Christ affirms his divinity, and Christ in turn appointed the Pope himself, or the body of Bishops led by the Pope, guided by the Holy Spirit, to offer infallible guidance on questions of faith and morals whose answers are found within the Word of God, comprised of both Sacred Tradition and Sacred Scripture. But liberal Roman Catholics do not affirm that the Bible is without error, even when interpreted correctly by the Pope or tradition.
The Eastern Orthodox Church also believes in unwritten Tradition and the written Scriptures. However, they hold that the infallibility or authority of the Magisterium belongs to all the bishops, not just the Roman bishop.