What is the purpose of scripture?

I believe the scriptures have been given to us for many purposes. I'll try to briefly outline some of my thoughts on this matter. This is by no means an exhaustive list.

1. To teach doctrine/testify of Christ - a very basic purpose is to declare the divinity of Christ, and teach proper doctrine regarding the gospel.

2. To grant us a portion of the Holy Spirit - reading the scriptures is different than reading an ordinary book. Reading the scriptures brings the Holy Spirit into your life.

3. To record prophecy/blessings - this way people can see the fulfillment of prophecies as a further testimony of God

4. Proof of the latter-day restoration - I believe that a major reason for the existence of the Book of Mormon is as a witness of the latter-day restoration. I think this is what is being referred to when writers in the Book of Mormon mention the "wise purpose" that they do not know.