What was the purpose of the Tree of the knowledge of good and evil

To me, there’s enough about the story that doesn’t add up or make sense if you take it at the strictly literal, surface level that I’m pretty sure we’re not supposed to take it at the literal, surface level, but rather to read it as allegory or metaphor or parable. Which might be the point that @C_K_Dexter_Haven was trying to make here:

I suspect that allegory has fallen out of favor somewhat, and that people today are less adept at recognizing and appreciating it than in the past.

The fact that it’s called “The Tree of Knowledge of Good and Evil”—that’s the kind of thing that you often find in allegory, making the abstract concrete and giving it a label like that.

The bit about Adam and Eve suddenly realizing they were naked and being ashamed of it is, to me, another clue. Is eating the fruit a metaphor for growing up? Little kids often have no shame or embarrassment about running around naked, but when they get older they develop modesty. Or is it a metaphor for the human species becoming more than just another animal? Other animals don’t wear clothes or have any issue with nakedness. Or is it something else, that still may be analogous or reminiscent of one or both of these?