I believe He put it there on purpose. Adam and Eve needed to understand both good and evil in order to be able to learn and progress. More significant, though, is the question of why He permitted Lucifer/Satan to tempt them. They would have had free will (i.e. free agency, freedom of choice, etc.) whether Satan was there or not. He told them not to eat that particular fruit, and He told them what the consequences for their disobedience would be. Nothing more was necessary had He simply wanted to allow them to choose for themselves. What nobody has ever been able to explain to my satisfaction is why He permitted Lucifer/Satan to tempt them. When you stop and think about it, He not only knew what was going to happen, He put them in a position where they were almost guaranteed to succumb to temptation. They knew they had been told not to eat the forbidden fruit, but since they didn't understand how serious disobedience was and were tempted with godhood, how else could we expect them to respond? The bottom line is that God not only knew what was going to happen, without actually forcing them to make the decision they did, He definitely set the stage to facilitate the outcome He knew would ultimately be the most beneficial to them.