The word “only” is inserted in his conclusion to draw attention to its importance. Righteous living is truly rare, and it has been so from the beginning, from Adam and Eve until now.
After this qualification, Solomon immediately asserts that God did not create human beings to sin but to live righteous lives. He is implying that we should stop blaming God for all of mankind's troubles—that we get ourselves into this mess we call life. God made us upright, but we all have deliberately chosen to sin.
Undoubtedly, he is reflecting on the early chapters of Genesis, where a clear pattern of deliberate, willful sin appears. Genesis 1:31 states God's evaluation of His creation: “Then God saw everything that He had made, and indeed it was very good.” Will we challenge God's judgment of what He had just created? Adam and Eve had already been created at this point, and God judged what He had made as “very good.”
They were not flawed by sin, and God had not placed in them a mechanism to sin deliberately. They had not been created to live fractured, sinful lives but upright, righteous lives. In terms of sin, whatever became part of them occurred after this point. He did not entrap them. However, they were capable of sinning because God created them with minds able to learn, discern, and make choices between options. Sinning was something they opted to do.
Genesis 6:5 suggests an interesting connection between the overwhelming sinfulness of the days of Noah and Solomon's conclusion in Ecclesiastes 7:29: “Then the LORD saw that the wickedness of man was great in the earth, and every intent of the thoughts of his heart was only evil continually.” The intriguing relationship is between the word “schemes,” “inventions,” or “devices,” depending on what translation is used in Ecclesiastes 7:29, and the word “intent” in Genesis 6:5. While not the same word, both derive from the same root, indicating thinking and/or planning. In both contexts, the thinking is being done with evil intent. That is, the ones doing the devising are deliberately planning evil.