Did people believe in mythology literally?

Of course, Socrates was executed for impiety, which suggests that the rest of Athens took religion more seriously than he did.

Well, it depends, doesn’t it, upon whether that charge was really the reason. If you read I.F. Stone’s book on the Trial of Socrates, or the intro to the Penguin edition of The Trial, or a number of other sources, they hold that the charge was simply the excuse, and that Socrates’ real crime was corrupting the young and hanging out with liabilities like Alcibiades.
Besides, Plato has Socrates say that this is the opinion of the wise, and there are other quotes for others (like Euhemerus, cited above) that can be used to show that literal belief in the gods and myths wasn’t universal. I just chose Socrates because he was famous, and I had his quote at hand.

And some that do don’t see “believing the wrong thing” as being the kind of thing one would get a really bad afterlife for doing. In modern Judaism, for example, the things you do are considered much more important than the things you believe, and we don’t believe that everyone who believes differently than we do is going to hell. The idea that everyone who doesn’t believe in our stories is going to hell is very much a Christian and Muslim idea, not one that is universal to all religions.

Or that they didn’t like what he had to say on non-religious topics, and they wanted an excuse to get rid of an annoying person. There are many other examples in history of using religion as an excuse to get rid of someone.

As other have pointed out, there was a range of opinion, but I suspect more folks treated these as “good stories”; Dr. Drake’s description is IMO quite apt.

Religion in ancient societies did not provide the “purpose for living” seen in more modern religions; that was left by and large to the philosophers. Stoicism, for example, was a reasoned approach to life that had much in common with Christian morality. The closest these philosophies would get to the question of the gods was in teleological arguments regarding the origin and end of the universe as a whole.

I also think the various temples/oracles/festivals at best answered a traditional or superstitious need in ancient societies. This was certainly the case in Rome, where a goddess like Furrina continued to be “worshipped” even though her original purpose was unknown in the time of Cicero. The inertia of a state-sponsored tradition is all that kept Furrina (and, perhaps, a lot of the older deities) alive.

These two factors IMO made it far less likely that whatever stories religion was based on would be taken literally. There was no impetus therefore to create a Greek/Roman equivalent to Ezra, and the stories were lest pretty much to the historians/poets.