God was testing them
Maybe. But I don't think so.
Usually tests are a measure of learning, achievement or skill. What was being tested there? And after a test you get to review the results so you can do better. In what way did that happen?
If this really was a test, why were the consequences permanent? Why did the fruit actually change them? Why not just say
an ordinary tree was The Tree of Knowledge of Good and Evil for test purposes? Did it reall
y need to be the TKGE?
And why were they punished for failing the test? Does anyone test their kids by placing a cookie jar in the middle of the living room, tell them not to eat cookies and then ground them for life when they do? You'd have to be some kind of lunatic to do that.
And why did yhwh not just undo the effects and have a "teaching moment"? He's omnipotent, right? He could have gotten the sin out just by willing it.
He could have sat down with Eve and her slow witted mate and explained what they did wrong. "Sorry, you two. You are not ready to have moral judgment. I should not have let the snake in here, but I really need you guys to listen to me. We'll work on that for a while. Until then, I'll just keep that Tree some place you can't reach. Got it? Okay. Now, go play."
The whole thing is crazy whether you take it literally or figuratively.
An alternative explanation is yhwh was actually evil and wanted his new people to not have moral judgment, ever. He actually had evil things in store, and if they gained moral judgment, they would not go along with his villainous plans. If that is so - and that makes a heck of a lot more sense to me - then the snake saved them and Eve is a courageous, smart hero.