Introduction
This is a Good Question: What is asked is, "Did God create evil?"
We have no problem with the "good" in the Tree of the Knowledge of Good and Evil; in Gen. 1:31 it says,
"And God saw every thing that he had made, and, behold, it was very
good. And the evening and the morning were the sixth day."(KJV)
In commenting on what "good" means, Keil and Delitzsch write in their commentary,
"God saw His work, and behold it was all very good; i.e., everything
perfect in its kind, so that every creature might reach the goal
appointed by the Creator, and accomplish the purpose of its existence.
By the application of the term "good" to everything that God made, and
the repetition of the word with the emphasis "very" at the close of
the whole creation, the existence of anything evil in the creation of
God is absolutely denied, and the hypothesis entirely refuted, that
the six days' work merely subdued and fettered an ungodly, evil
principle, which had already forced its way into it."
Therefore, everything that God created was good, in it's purpose and kind, including the venom of the snakes, the dangerous animals, the quicksand pits, and yes, even the mosquitoes. Each had a purpose, given by God to fulfill; there was nothing created that was not "good".
So then, how can God create a Tree that is both "good" and "evil"?
One could create a hypothesis that "to God it is good, but to man it is evil", but then the snake venom, dangerous animals, and mosquitoes would have also been added as "evil", but that's not the case-they are good, fulfilling their purpose, just not for man's direct benefit. In Isa. 45:7, it says
"I form the light, and create darkness: I make peace, and create evil:
I the LORD do all these things."(KJV)
Again, in Keil and Delitzsch's Commentary, they say,
"The meaning of the words is not exhausted by those who content
themselves with the assertion, that by the evil (or darkness) we are
not to understand the evil of guilt (malum culpae), but the evil of
punishment (malum paenae). Undoubtedly, evil as an act is not the
direct working of God, but the spontaneous work of a creature endowed
with freedom"
Under this constraint then, the word "רָ֑ע"(ra‘) is understood to mean "calamity", which is an outpouring of judgment against evil, and not the act of evil itself.
Did God Create Evil?
If evil is the response of a fallen creation, endowed with a free will from God, their creator, then what do we make of a "Tree" which possesses the knowledge of "Good" and "Evil"?
To respond to this, we must recite the attributes of God: 1) That He is a Holy God.
All throughout the Bible, both the Old and New Testaments, God is holy, and we, if we are to enter into His Presence, are to be holy also. The Psalmist in Ps. 5:4 says,
"For thou art not a God that hath pleasure in wickedness: neither
shall evil dwell with thee."(KJV)
Again, it says in Hab. 1:13,
"Thou art of purer eyes than to behold evil, and canst not look on
iniquity".(KJV)
A holy God, of whom the cherubim in Isa. 6:3, and in Rev. 4:8 say,
"and they rest not day and night, saying, Holy, holy, holy, Lord God
Almighty, which was, and is, and is to come."(KJV)
cannot be assigned with evil, indeed it is blasphemous to say so.
2) God does not tempt man; this is made clear in James 1:13-15,
"Let no man say when he is tempted, I am tempted of God: for God
cannot be tempted with evil, neither tempteth he any man: 14 But every
man is tempted, when he is drawn away of his own lust, and enticed. 15
Then when lust hath conceived, it bringeth forth sin: and sin, when it
is finished, bringeth forth death".(KJV)
What can be verified from Scripture is that God tests man, to see whether or not he will obey Him. In Gen. 22:1, it says,
And it came to pass after these things, that God did tempt Abraham,
and said unto him, Abraham: and he said, Behold, here I am.(KJV)
The word "tempt" here is "נִסָּ֖ה"(nis·sāh) which in the BDB means
*test, try, prove, tempt [but not in modern sense of the word: see
Deuteronomy 6:16; Psalms 453, 483]
a. God tests or proves Abraham Genesis 22:1 (E), Israel Exodus 15:25;
Exodus 20:20 (E), Exodus 16:4 (J), Deuteronomy 8:2,16; Deuteronomy
13:4; with בְּ Judges 2:22; Judges 3:1,4; tribe of Levi Deuteronomy
33:8 (poem); Hezekiah 2 Chronicles
32:31; psalmist Psalm 26:2.*
So, in reference to the Tree of the Knowledge of Good and Evil, God tested Adam and Eve, to see whether or not they would obey Him, and only in that regard can it be said that the "Tree of the Knowledge of Good and Evil" was good.
How Are We to Understand the Tree of the Knowledge of Good and Evil?
This answer gets to the heart of the question, "Did God create evil?", because understanding in what context the "Tree of the Knowledge of Good and Evil" exists confirms whether or not God created this "Tree".
We understand from Gen. 2:19,
"And out of the ground made the LORD God to grow every tree that is
pleasant to the sight, and good for food; the tree of life also in the
midst of the garden, and the tree of knowledge of good and evil."
that there is a distinction from every other tree; in Gen. 1:29 He says,
"And God said, Behold, I have given you every herb bearing seed, which
is upon the face of all the earth, and every tree, in the which is the
fruit of a tree yielding seed; to you it shall be for meat."(KJV)
But we have to be reminded at this point, that man is body, soul, and spirit, as God created him. In 1 Thess. 5:23, it says,
"And the very God of peace sanctify you wholly; and I pray God your
whole spirit and soul and body be preserved blameless unto the coming
of our Lord Jesus Christ."
It is in the context of the "soul"(mind, will and emotions) that we are to understand the 2 "Trees" which are mentioned parenthetically 'after' the seed bearing trees, which we know from Gen. 1:29 were good to eat. The term "eat" can be used both physically and figuratively; the word "אֲכָלְךָ֥" allows for both meanings. We see throughout Scripture that "eating" is used figuratively; in Ps. 34:8 it says,
"O taste and see that the LORD is good: blessed is the man that
trusteth in him."(KJV)
In Jer. 15:16 it says,
“Thy words were found, and I did eat them; and thy word was unto me
the joy and rejoicing of mine heart: for I am called by thy name, O
LORD God of hosts.”
Again, "וָאֹ֣כְלֵ֔ם"(wā·’ō·ḵə·lêm) is a derivative of "אֲכָלְ" which uses the word "eat" to describe both physically and spiritually the action of digestion.
What is interesting is both "trees" are to be understood figuratively, as acquiring knowledge and life both dwell outside of the realm of physical digestion; yet the commandment not to eat only pertains to the "Tree of the Knowledge of Good and Evil", it does not pertain to the "Tree of Life". They were allowed, and I believe encouraged to eat from the Tree of Life, all that they wanted, and as much as they wanted.
So, who or what is this "Tree of Life", and how is it distinguished from the "Tree of the Knowledge of Good and Evil"?
Jesus said in John 6:35,
"I am the bread of life: he that cometh to me shall never hunger; and
he that believeth on me shall never thirst."(KJV)
He further says,
"I am the living bread which came down from heaven: if any man eat of
this bread, he shall live for ever:"(KJV)
He even goes further to say, vs 57,
"As the living Father hath sent me, and I live by the Father: so he
that eateth me, even he shall live by me."(KJV)
Jesus, therefore, is the "Tree of Life" in the middle of the Garden of Eden; Adam and Eve, who were sinless from creation, were encouraged to 'eat' from this "Tree". In Rev. 22:14 it says,
"Blessed are they that do his commandments, that they may have right
to the tree of life, and may enter in through the gates into the city."(KJV)
The choice for Adam and Eve, in the Garden of Eden was to choose Christ, who was identified in the Garden as the "Tree of Life". There's would have been eternal life, and in Gen 3:22 God said,
"And the LORD God said, Behold, the man is become as one of us, to
know good and evil: and now, lest he put forth his hand, and take also
of the tree of life, and eat, and live for ever."(KJV)
Therefore, by man choosing to "know evil", he not only forfeited eternal life, but he also relinquished "knowing good", because everything on the Tree of Life was beneficial to man-as opposed to the "Tree of the Knowledge of Good and Evil" which an individual would have to discern the difference-apart from the knowledge of God.
Where Did the Tree of the Knowledge of Good and Evil Come From?
We have shown that God is not the author of evil, neither was it God's intention that man would "know evil". The Problem was that evil existed in God's creation, in the form of Satan, an angel created by God, who used his will to defy and oppose all that God did.
We 1st encounter Satan in Isa. 14:12,
"How art thou fallen from heaven, O Lucifer, son of the morning! how
art thou cut down to the ground, which didst weaken the nations!"(KJV)
and we further see from Ezekiel's description of the King of Tyre that he wasn't talking about the "king",
Thus saith the Lord GOD; Thou sealest up the sum, full of wisdom, and
perfect in beauty. 13 Thou hast been in Eden the garden of God; every
precious stone was thy covering, the sardius, topaz, and the diamond,
the beryl, the onyx, and the jasper, the sapphire, the emerald, and
the carbuncle, and gold: the workmanship of thy tabrets and of thy
pipes was prepared in thee in the day that thou wast created. 14 Thou
art the anointed cherub that covereth; and I have set thee so: thou
wast upon the holy mountain of God; thou hast walked up and down in
the midst of the stones of fire. 15 Thou wast perfect in thy ways from
the day that thou wast created, till iniquity was found in thee.
We see that God had an enemy, who was with Him and saw His creation, who was created by God as an angel of light(Lucifer-Bearer of Light), and yet through his rebellion, became ha-Satan, the "Opposer" of all that God does.
What is important is that God never told Adam and Eve about Satan, His intention was that man would never know evil. He 'allowed' Satan in the form of a "Tree"-the Tree of the Knowledge of Good and Evil to test man, to see whom he would obey. In order to test him, he had to offer an alternative-"death" as opposed to "life". Jesus said in John 8:44,
"Ye are of your father the devil, and the lusts of your father ye will
do. He was a murderer from the beginning, and abode not in the truth,
because there is no truth in him. When he speaketh a lie, he speaketh
of his own: for he is a liar, and the father of it."(KJV)
When the serpent spoke to Eve in Gen. 3:5,
"For God doth know that in the day ye eat thereof, then your eyes
shall be opened, and ye shall be as gods, knowing good and evil."
he was offering a lie, "You shall be as gods(elohim)" to know only what God knows-that He has an enemy, and you have to choose who you will obey; Satan, who is presented here as the "Tree of the Knowledge of Good and Evil". or God, who is presented as the "Tree of Life". The means by which man would know either was through knowledge, acquired from a "Figurative Tree" which gave that knowledge. God was represented by the Tree of Life, Satan was represented by the "Tree of the Knowledge of Good and Evil" in that he had known the works of God, and could dispense their knowledge, yet was perverse and corrupted(evil) which he used to harm God and His Purposes.
Conclusion
The Tree of the Knowledge of Good and Evil is a figurative representation of the knowledge that Satan had to corrupt and harm the Purposes of God through man. Though all true knowledge is from God, God was and is not the 'author of evil", therefore a "Tree" containing evil can never be associated with God. Since we've proved these "Trees" are figurative, rather than Literal, they are associated to the choices which man must make: The Tree of Life-which is Christ, and the "Tree of the Knowledge of Good and Evil" which is Satan's tree. These "trees" are mysteries: the "Tree of Life" is the mystery of Godliness(1 Tim. 3:16), and the "Tree of the Knowledge of Good and Evil" is the Mystery of Iniquity(2 Thess. 2:7). Satan is a hideous monster- described as a "serpent" or dragon in Rev. 20:2,
And he laid hold on the dragon, that old serpent, which is the Devil,
and Satan, and bound him a thousand years,
and indeed, he spoke through the mouth of a serpent in Gen. 3. But the means by which he tempted Adam and Eve was in the form of a tree which,
"and when the woman saw that the tree was good for food, and that it
was pleasant to the eyes, and a tree to be desired to make one wise."
This is Antichrist, which was seen from the Garden of Eden as opposing the Will of God, offering men the 'lie' that if they just 'eat' more knowledge, they can be as "God".