God put the tree in the garden to test humanity but he must have known what was going to happen so the more interesting question is ‘why did he put the tree there in the first place?’.
Actually, why create Lucifer, knowing he would fall and tempt Eve via the tree is more so than that...