How was the Bible put together? How did history decide which books were in and which ones were out?
The current list of books in the Bible - known as the "canon" - was put together in different ways for the Old Testament and New Testament. But despite what some fiction authors might like to claim, the process was not secretive or mysterious.
...there was very little controversy over the canon of the Old Testament. Hebrew believers recognized God’s messengers and accepted their writings as inspired of God. While there was undeniably some debate in regards to the Old Testament canon, by A.D. 250 there was nearly universal agreement on the canon of Hebrew Scripture...
For the New Testament, the process of the recognition and collection began in the first centuries of the Christian church. Very early on, some of the New Testament books were being recognized. Paul considered Luke’s writings to be as authoritative as the Old Testament (1 Timothy 5:18; see also Deuteronomy 25:4 and Luke 10:7). Peter recognized Paul’s writings as Scripture (2 Peter 3:15-16). Some of the books of the New Testament were being circulated among the churches (Colossians 4:16; 1 Thessalonians 5:27). Clement of Rome mentioned at least eight New Testament books (A.D. 95). Ignatius of Antioch acknowledged about seven books (A.D. 115). Polycarp, a disciple of John the apostle, acknowledged 15 books (A.D. 108). Later, Irenaeus mentioned 21 books (A.D. 185). Hippolytus recognized 22 books (A.D. 170-235). The New Testament books receiving the most controversy were Hebrews, James, 2 Peter, 2 John, and 3 John...
The councils followed something similar to the following principles to determine whether a New Testament book was truly inspired by the Holy Spirit: 1) Was the author an apostle or have a close connection with an apostle? 2) Is the book being accepted by the body of Christ at large? 3) Did the book contain consistency of doctrine and orthodox teaching? 4) Did the book bear evidence of high moral and spiritual values that would reflect a work of the Holy Spirit?