Answer:

. . . but of the tree of the knowledge of good and evil you shall not eat, for in the day that you eat of it you shall surely die (GENESIS 2:17).

JOHN 3:16ROMANS 5:12

Have you ever played with a puppet? The puppet will do whatever you want it to do because it is on your hand. You are moving it, talking for it, and making it sit, stand, and dance. Well, when God made Adam, He didn’t want him to be a puppet, but He wanted Adam to truly love Him. 

The command about the tree of the knowledge of good and evil was God’s test to see if Adam really did love God enough to totally obey Him. But Adam failed the test. He sinned against God and did something God told him not to do. This was a very bad day for all of us because Adam was the head of the whole human race—the very first man. When he failed God’s test, he brought sin into the world, and now all of us have the same sin nature from Adam.

Source: https://answersingenesis.org/kids/bible-questions/why-did-god-put-the-tree-in-the-garden-of-eden/