Thank you for the foreknowledge question, “Why did God punished Adam and Eve if he knew they would sin?”
The question focuses on the sovereignty of God and the limited freedom of humans. God is sovereign and he has a plan for his creation. That plan is only known to him unless he reveals it to humans.
The reason why God “punished” Adam and Eve is because he forewarned them if they ate the forbidden fruit. The penalty would be death. If God didn’t fulfilled his word, he would not be trustworthy or righteous. This may lead to humans hearing God’s command and ignoring it since God wouldn’t or may not do anything at all. Humans may think that they can get away with anything since God doesn’t know what is happening or doesn’t care what happens on earth. God’s actions showed that he is faithful to his own word.
Certainly God knows whether a person will obey or disobey his commands, but each person is given a choice to obey or disobey his/her own conscience and the commands of God. The fact that God knows everything, being omniscience, does not make the choice by man less real.
From a hypothetical point of view without the record of Adam and Eve’s action, they could have indefinitely remained in the Garden by not eating the forbidden fruit. That is a possibility and God could have designed that they wouldn’t sin at all. It is in one sense by hindsight that one can say that God “knew” Adam and Eve would sin, but prior to that point, no one knows.
For example, there are speed limits. Do patrolman or judges know that there would be speedsters? Does that mean that the patrolman couldn’t give a speeding ticket or the judge enforcing the fine because they “knew” that there would be violators? Of course not. The signs are posted for everyone to read and to obey. It was not a deception but a choice by the driver to exceed the speed limit. Even as parents, we established family rules. Do the parents know that child/ren will disobey the rules. Absolutely, but that doesn’t mean that the parents can’t discipline/punish that child for disobeying their rules. If the parents do not discipline that child, then those rules are meaningless but only suggestions.
It’s not a perfect analogy, but one can understand that by establishing a rule/command is to test the obedience or willingness to stay within the set boundary by the person. It is for that person’s well-being as well as for others.
Certainly God could have just made the Tree of Life without the Tree of the Knowledge of Good and Evil and determined that Adam and Eve would never sin against him. If God did that, it would mean that Adam and Eve would have no “choice” in expressing their own independence. They would be like “robots” without any self-determination.
Adam and Eve knew what it was like to live in obedience to God with its blessing. When they sinned against God, they knew what i was like to live in disobedience to God with its consequences. They experience the blessing of God and now they were to experience the discipline of God even as they experienced the death of their second born son, Abel. How they must have regretted eating that forbidden fruit. They had to live with their decision and suffer their consequences.
SUMMARY: Adam and Eve accepted their consequences for it was their choice to eat the forbidden fruit. God didn’t force them to do something against their will. It was the exercise of their limited choice.
For more perspectives:
https://www.quora.com/Why-did-God-punish-Adam-and-Eve-if-he-knew-they-would-sin-1