Are good things never forbiddenl? Is it not a good thing for a young person to learn to drive a car? But a good father may forbid his 9-year old son from doing so. It is necessary for the child to mature first.
I see the same thing with the tree of knowledge of good and evil. It is a good thing to be able to distinguish good from evil.
Hebrews 5:14 But solid food is for the mature, for those who have their powers of discernment trained by constant practice to distinguish good from evil.
Why did God place the tree of knowledge of good and evil in the garden? Did he want to tempt Adam and Eve with evil? I don’t think so. They were newly created. I think He wanted them first to mature—perhaps to eat first from the tree of life (He never forbade them from eating from that tree.)
After maturity, they would be ready to eat from the tree of knowledge of good and evil. But Satan tempted them to do things in reverse. Satan often give a twist to God’s commands in a way that they will not be properly carried out.