As a student of 'academic' New Testament studies, I can honestly say that each work in the New Testament was written by humans and that each writer never knew that his writing would someday be given the status of the sacred scripture. The designation of those writing being the Sacred Scripture is a result of consensus among the early Christians. Around 380 A.D. the early church decided to include 27 separate books into the Canon of the New Testament. In other words, the New Testament became a sacred and holy book because the church said so, and folks agreed. Other than that, it's a collection of human words. Each book represents historical context of its time.
Did God actually 'author' each book? Did God actually inspire each writer? Is each word in the Bible God's word? The answers are: yes, yes, and yes, if you are a Christian! These answers are, however theological/confessional in nature. The answers are "Maybe," if you are a historian/biblical scholar, since answers to these questions are beyond the scope of scholarly inquiries. As to the question, "Why was the New Testament written?", the answer is: To make a case is that the executed criminal from a small town of Nazareth is actually the Messiah.