How were the books of the Bible chosen?
The 39 books of the Old Testament form the Bible of Judaism, while the Christian Bible includes those books and also the 27 books of the New Testament. This list of books included in the Bible is known as the canon. That is, the canon refers to the books regarded as inspired by God and authoritative for faith and life. No church created the canon, but the churches and councils gradually accepted the list of books recognized by believers everywhere as inspired.
It was actually not until 367 AD that the church father Athanasius first provided the complete listing of the 66 books belonging to the canon.
He distinguished those from other books that were widely circulated and he noted that those 66 books were the ones, and the only ones, universally accepted.
The point is that the formation of the canon did not come all at once like a thunderbolt, but was the product of centuries of reflection.
Let's look first at the Old Testament. Obviously the first five books (sometimes called the Torah or the Pentateuch) were the first to be accepted as canonical. We're not sure when this occurred, but it was probably during the fifth century before Christ. Of course, the Hebrews had the "Law" for many centuries already, but they certainly did not pay very good attention to it. It was probably the work of the prophets Ezra and Nehemiah that restored it to general use and fixed it once and for all as authoritative.
How about the rest of the Old Testament? The prophets' writings were also not brought together in a single form until about 200 BC. The remaining Old Testament books were adopted as canonical even later. The Old Testament list was probably not finally fixed much before the birth of Christ. The Jewish people were widely scattered by this time and they really needed to know which books were the authoritative Word of God because so many other writings claiming divine authority were floating around. With the fixing of the canon they became a people of one Book, and this Book kept them together.
Nor is there a single date when we can say that the canon of the New Testament was decided. In the first and second centuries after Christ, many, many writings and epistles were circulating among the Christians. Some of the churches were using books and letters in their services that were definitely spurious. Gradually the need to have a definite list of the inspired Scriptures became apparent. Heretical movements were rising, each one choosing its own selected Scriptures, including such documents as the Gospel of Thomas, the Shepherd of Hermas, the Apocalypse of Peter, and the Epistle of Barnabas.
Gradually it became clear which works were truly genuine and which mixed truth with fantasy. By the end of the fourth century the canon was definitively settled and accepted. In this process Christians recognize the providence of God in providing us with his written revelation of himself and his purpose with the universe.
Questions still arise now and then about the canon. Some wonder why just these 66 booklets were chosen. Why not 65 or 67? Why was the sometimes puzzling booklet of Jude included to the exclusion of other edifying scriptures? To these questions we reply that these books are the ones that God himself has chosen to preserve for us, and he has not told us exactly why. Together they form an immeasurable treasure, and in them we find God's matchless gift to his people. Here we are moved simply to trust in his providence as he led his people through the years and gave us the most honored and powerful and comforting volume in the history of humanity, the book known as the Bible.
And in his providence he has provided this treasure for you as well. Take up its ancient words and mandates and live by them! As you steep yourself in its pages, your heart will find peace at last.