The Bible was written in two parts, the Old Testament (39 books) and the New Testament (27 books) because the Old Testament described the history of the people that God chose to be the ones through whom the Messiah would come. Therefore, it contains the history of God's people (the Jews) and also includes prophecies of the coming of Jesus the Messiah.
The New Testament was written as a demonstration of the fulfillment of the Old Testament prophecies of Jesus as well as letters written to various churches and individuals informing them of proper Christian behavior.
The time between the last book of the Old Testament and the first book of the New Testament is just over 400 years.
Since there is a natural 400-year gap between the last book of the Old Testament and the first book of the New Testament, the Bible is divided up into those two parts.