Solomon was given knowledge through God, so much knowledge but he was tempted and fell from the good path and led into evil.
The following will show (in his own words) his fall (bolded part mine):
128. And I Solomon glorified God, and adorned the Temple of the Lord with all fair-seeming. And I was glad in spirit in my kingdom, and there was peace in my days. And I took wives of my own from every land, who were numberless. And I marched against the Jebusaeans, and there I saw Jebusaean, daughter of a man: and fell violently in love with her, and desired to take her to wife along with my other wives. And I said to their priests: “Give me the Sonmanites (i.e. Shunammite) to wife1.” But the priests of Moloch said to me: “If thou lovest this maiden, go in and worship our gods, the great god Raphan and the god called Moloch.” I therefore was in fear of the glory of God, and did not follow to worship. And I said to them: “I will not worship a strange god. What is this proposal, that ye compel me to do so much?” But they said: “. . . . .2 by our fathers.”
1. Song of Sol. vi. 12.
2. utheìs (sic) stands in the MS.; perhaps taîs theaîs should be read.
129. And when I answered that I would on no account worship strange gods, they told the maiden not to sleep with me until I complied and sacrificed to the gods. I then was moved, but crafty Eros brought and laid by her for me five grasshoppers, saying: “Take these grasshoppers, and crush them together in the name of the god Moloch; and then will I sleep with you.” And this I actually did. And at once the Spirit of God departed from me, and I became weak as well as foolish in my words. And after that I was obliged by her to build a temple of idols to Baal1, and to Rapha, and to Moloch, and to the other idols. 1. Fem. So Rom. xi. 4.
130. I then, wretch that I am, followed her advice, and the glory of God quite departed from me; and my spirit was darkened, and I became the sport of idols and demons. Wherefore I wrote out this Testament, that ye who get possession of it may pity, and attend to the last things1, and not to the first. So that ye may find grace for ever and ever. Amen. 1. Cp. Rev. ii. 19.
It’s necessary to know this before looking into anything further that he talks about, because what he writes about is good and bad. Everything must be done for God, and not for evil.
For more information on the Key of Solomon click here.