How do we know that the books of the Bible are the "right" books? How were the Bible's contents determined?
The early church fathers determined which texts qualified as inspired scripture based on fairly simple and straightforward criteria. First, the author of a text was to be someone who had Apostolic authority. The position of apostle is one of a specific spiritual gifting of the Holy Spirit, which is no longer available to the church today. All New Testament canon was authored by apostles.
The gift of apostleship could only be given by the Lord Jesus, and it was bestowed upon two groups of men. First, the gift of apostleship was given to the 12 that followed Jesus during His lifetime (Judas, an unbeliever, was not a true apostle).
This first group of apostles was men who followed Jesus and who participated in the baptism of John the Baptist. The circle of 11 became 12 with the selection of Mathias in Acts 1:19-26. In those verses we see the apostles mentioning the requirement that only men who had followed Jesus since John the Baptist were eligible to be one of the 12.
The second group of apostles was men who were appointed by a personal encounter with the resurrected Christ. This second group included men like Paul (see 1Cor 9:1), Barnabas (Acts 14:14), James (1Cor 15:7 & Gal 1:19) as well as others.
Men couldn't simply claim the office of apostle; they had to demonstrate that the Lord had indeed granted them that office. All apostles validated their claims to apostleship through unique supernatural abilities to perform miracles, especially miracles that mirrored those that the Lord Jesus Himself performed.
For example, the apostles are seen in Acts and in the Epistles raising men from the dead, performing miraculous healing, bestowing the Holy Spirit upon new believers, surviving bites from deadly snakes and other miraculous signs. These were not abilities common to all believers but were unique to apostles. The purpose in these unique supernatural abilities was to validate their office and authority in the early church. You can see this principle described in scripture in many places, including 2Cor 12:12 and Hebrews 2:3-4.
Men who held the office of apostle were recognized as the authority within the early church, and the Church understood their authority under Christ couldn't be challenged nor questioned by men, since their authority came directly from the Lord. As an example, read how Paul refers to his Christ-given position within the church in 1Cor 4:18-20 and again in the salutations in Colossians and 1Timothy.
In the case of Paul's letter to the Corinthians, it's obvious that some in the Corinthian church had challenged Paul's authority and teaching, so Paul tells the church to let these rebels within the church prove their authority by demonstrating their power. If they are truly speaking with God's authority, let them show God's power as proof of their authority. Obviously, Paul knew these false teachers couldn't demonstrate apostolic power, so Paul's challenge would have silenced them.
While the formal canon of scripture wasn't determined until centuries after Christ's death, the letters of the apostles were viewed as scripture from their inception by the early Church. In fact, one of the criteria used by the Church fathers in determining if a work should be included in the canon of scripture was whether it had been regarding as inspired from the earliest days of the Church. The fact that these works originated with an apostle was sufficient to regard them as inspired, since one of the purposes of the role of the apostle was to communicate God's word to the Church.
So, when the final canon was assembled in AD 327, the council at that time merely acknowledged and confirmed what the Church had long before agreed were the inspired works of Scripture. The 27 books of the New Testament were all validated as authorized by apostles and embraced as inspired text by the early Church without dispute. (The 39 books of the Old Testament canon already existed as the Jewish Bible, based on the Masoretic text, and therefore they were adopted unchanged into the Protestant canon.)
We could draw an analogy to the way a committee might assemble today for the purpose of verifying which ancient records were the authentic founding documents of the United States of America. The committee would certainly confirm that the Declaration of Independence, Constitution and other well-known documents were authentic while rightly rejecting later documents like the Gettysburg Address – documents that may have historical value yet failed to meet the specific criteria guiding the committee's judgment. In a similar manner, only works that met the strict test of apostolic authorship were permitted into the canon.
Glancing down the list of authors in the New Testament, all the authors are men universally accepted as apostles in the first-century church. Only the writer of Hebrews remains unknown to us. The early church knew the author and acknowledged him to be an apostle, though his name has been lost to history. Many suspect the author was either Paul or Barnabas, both apostles.
Therefore, the books that compose the canon of scripture were not selected in an arbitrary nor capricious fashion. They were selected based on a simple but rigorous standard of authors with proven apostolic authority, each man proving his authority with apostolic powers validated by witnesses and with instructions found trustworthy based on internal consistency with other scripture.
With the death of the last apostle (John), the canon was closed until the return of Christ Himself, since He alone bestows the apostolic authority required to author new scripture. This is why John ends Revelation in the way he does:
Rev. 22:18 I testify to everyone who hears the words of the prophecy of this book: if anyone adds to them, God will add to him the plagues which are written in this book;
Rev. 22:19 and if anyone takes away from the words of the book of this prophecy, God will take away his part from the tree of life and from the holy city, which are written in this book.
Those verses come at the very end of the Bible, and Christ included them in John's book as a warning to anyone who would desire to expand scripture beyond what God Himself provided. It isn't merely a warning concerning altering the words of Revelation alone, but it also reflects the fact that all Biblical revelation was meant to end with that book (the last book written chronologically).
Secondly, the book of Hebrews tells us this:
Heb. 1:1 God, after He spoke long ago to the fathers in the prophets in many portions and in many ways,
Heb. 1:2 in these last days has spoken to us in His Son, whom He appointed heir of all things, through whom also He made the world.
While revelation came in a variety of ways in past ages, in the age that follows Christ's death and resurrection, His words and the words He imparted through His apostles are the final revelation to men. There will be no further form nor source of revelation. This is because God the Father has reserved the highest honor for His Son. He would dishonor His Son if He were to provide men with a competing source for knowledge of the Father, since His Son is the Word. The Son is to be the culmination of all revelation to men, according to scripture.
Obviously, there are many false works wish to masquerade as inspired text, and since the test of apostleship is so clear and irrefutable, many schemes have been concocted to overcome this test. Some false books have tried to gain credibility by claiming apostolic authors or mystical origins.
For example, the supposed "gospel" of Timothy was rejected from the canon because the church fathers could not validate that the true author was the one named and because the text itself presented ideas and concepts not in harmony with other inspired text. This book and others like it included teaching that contradicted with other works of scripture which DO pass the test of apostleship, and therefore they were found to be uninspired.
Other works like Maccabees or the Book of Wisdom were written after the first century (i.e., after all apostles were gone) in an attempt to extend the written tradition of Jewish wisdom and historical texts, but they violate the New Testament principle that teaches all post-resurrection revelation must flow by and through Christ Himself. These books lack such authority.
On the other hand, some of these extrabiblical texts may have teaching value (just as this article has teaching value), but since they are not directly inspired by Christ through His Spirit, we cannot hold them to be scripture and thus inerrant. All extra-Biblical sources must be interpreted through the lens of inspired scripture, and when they contradict inspired works, they must be dismissed in favor of scripture.
You may be interested in reading another article on why the Apocrypha is not considered inspired scripture.