Shakespeare's Hamlet is full of moral instructions. For example, there is Polonius' famous advice to his son Laertes in Act 1, Scene 3. Polonius is portrayed as old and rather senile. Hamlet calls him a "tedious old fool." Nevertheless, the old man's advice to his son is full of practical wisdom.
Give thy thoughts no tongue,
Nor any unproportioned thought his act.
Be thou familiar, but by no means vulgar.
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Give every man thy ear, but few thy voice;
Take each man's censure, but reserve thy judgment.
Costly thy habit as thy purse can buy,
But not express'd in fancy; rich, not gaudy;
For the apparel oft proclaims the man,
And they in France of the best rank and station
Are of a most select and generous chief in that.
Neither a borrower nor a lender be;
For loan oft loses both itself and friend,
And borrowing dulls the edge of husbandry.
This above all: to thine own self be true,
And it must follow, as the night the day,
Thou canst not then be false to any man.
The best part of the advice comes at the end of his speech, and it is contained in a single line of iambic pentameter:
This above all: to thine own self be true.
Another good moral lesson is contained in the tempestuous meeting between Hamlet and his mother in Act 3, Scene 4. (We should keep in mind that this is really the great William Shakespeare who is talking to us through his characters and value his advice accordingly.) Hamlet is telling his mother how to break a bad habit, something we could all profit from learning.
Assume a virtue, if you have it not.
That monster, custom, who all sense doth eat,
Of habits devil, is angel yet in this,
That to the use of actions fair and good
He likewise gives a frock or livery,
That aptly is put on. Refrain to-night,
And that shall lend a kind of easiness
To the next abstinence: the next more easy;
For use almost can change the stamp of nature,
And either [ ] the devil, or throw him out
With wondrous potency.
A bad habit can be replaced with a good one. The first day is the hardest. Getting through that day makes it easier to get through the next one (for example, without smoking), and the next day is still easier.
Hamlet says "He likewise gives a frock or livery" because he means that the devil turned angel will give a metaphorical frock or dress to a woman and a metaphorical suit of livery to a man.
The idea of assuming a virtue if you have it not has been offered by more modern thinkers, including psychologist William James, who said:
If you want a quality, act as if you already had it.
There are many other moral lessons conveyed through dialogue or dramatic action. Hamlet’s procrastination is in itself a serious moral lesson. Claudius’ tormented conscience for having murdered his own brother is intended as a moral lesson. Laertes’ advice to Ophelia regarding Hamlet, and her advice to Laertes regarding his behavior while he is away at the university are both moral lessons.