Three things are to be observed concerning this book.
The author; who was Solomon, as is manifest both from the common consent of Jewish and Christian writers, and from the express words of the first verse. That he wrote it in his old age, is more than probable from divers passages in it, as, that he did it after his buildings, chap. 2:4, which yet took up twenty years of his life, 1Kings 9:10, and after some considerable enjoyment of them, and planting of gardens, and orchards, and reaping the fruit of them, chap. 2:5,6, and after long and much consideration and experience of all those methods in which men expect to find happiness, chap. 7:27, &c. So this book was written by him, as a publick testimony of his repentance and detestation of those wicked courses to which he had addicted himself: wherein he followed the example of his father David, who, after his sad fall, penned the fifty - first psalm. And the truth of this opinion may be confirmed by that expression, 2Chron 11:17. They walked in the way of David and Solomon; that is, wherein they walked, both before their falls, and after their repentance.
The method of it. For whereas there are some passages in it which seem impious; it must be considered, that it is in part dramatical; that Solomon speaks most things in his own name, but some things in the names of ungodly men, as is undeniably manifest both front the scope and design of the book, as it is expressed both in the beginning and in the conclusion of it, and from his serious and large disputation against those wicked principles and courses. And this way of writing is not unusual among both sacred and profane writers.
The design of it; which is, to describe man's true happiness, and the way leading to it. This he does both negatively, proving, that it is not to be found either in secular wisdom, or in sensual pleasures, or in worldly greatness and glory, or in abundance of riches, or in a vain profession of religion: and positively, shewing, that it is to be had only in the fear of God and obedience to his laws, which alone can give a man a chearful enjoyment of his present comforts, and an assurance of his everlasting happiness.