Not everything in the Bible is to be taken literally. And yet, what's written in the Bible is not just figurative or symbolic. Discernment, spiritual discernment, is needed for a true understanding.
Events in the Bible are real, but they can also be figurative. The stories recorded in the Bible aren't random events, they're selected by God for a purpose.
They are intended to teach us something by example or by way of illustration. Just as in life, where we can learn from the success or mistakes we make, we can learn from the successes, wisdom, and failures of others.