Our moral principles are forged analogically and the steel is hardened with logic.
That is: we (at least I) emulate admirable characters in stories and try to avoid behaviors we find deplorable. "What would Jesus do?" ask the Christians.
In his famous essay
In Defense of Poetry, Shelley compares Homer to Plato. The essay is available on line, and here's a snippet:
Homer embodied the ideal perfection of his age in human character; nor can we doubt that those who read his verses were awakened to an ambition of becoming like to Achilles, Hector, and Ulysses the truth and beauty of friendship, patriotism, and persevering devotion to an object, were unveiled to the depths in these immortal creations: the sentiments of the auditors must have been refined and enlarged by a sympathy with such great and lovely impersonations, until from admiring they imitated, and from imitation they identified themselves with the objects of their admiration.
We learn friendship from Don Quixote and Sancho, the dangers of a quest for perfection from Lancelot, and the power of love from Jean Valjean. Of course from Achilles we also learn the dangers of vanity, stubbornness and cruelty. Philosophy merely expounds on, justifies and clarifies these virtues and these faults.
I've started reading Harold Bloom"s
Where Shall Wisdom be Found, and he will doubtless have more to say on this subject.