One of the main themes that Shakespeare had in mind when writing Macbeth was to show how unchecked ambition, that of Macbeth and Lady Macbeth can be a destructive force. A power so great that it creates an imbalance in nature. Killing a worthy and rightful king is an evil act.
Macbeth is obsessed with and possessed by his desire to become king once he is given the prophecy by the witches. Even though he apparently loves his king in the beginning of the play, Duncan hails Macbeth as a courageous hero, bestowing on his another noble title, Thane of Cawdor, it is not enough.
Even though Macbeth starts out as a noble and honorable man, the idea of being powerful, the idea of sitting on the throne corrupts his soul. He gives up everything that he has and surrenders to the need to commit murder.
Once he has secured the crown and has indeed become King of Scotland, it is not enough. He becomes paranoid with guilt and continues to murder innocent people that he perceives as threats to his kingship.
Shakespeare wrote this play with a few facts from real Scottish history. His troupe of actors, The Kings Men, performed for their patron, King James of Scotland, who is honored in the scene with the eight kings followed by Banquo's ghost.
His intention in writing Macbeth was to entertain his audience, and to tip his hat to his benefactor, King James at the same time.
Two big questions! But no simple answers, I'm afraid.
As you can see above, it's possible to read Macbeth simply as a study of ambition and decide that its moral is "don't be ambitious" or "don't act on your ambition". But Shakespeare carefully makes things more difficult: by implying that the supernatural forces might be controlling Macbeth's actions, and that he might actually be an innocent party led towards his ruin.
Look at the witches casting a spell in one scene ("the charm's wound up!") and think about the dagger which appears to lead Macbeth to the murder. The dagger might just be "a dagger of the mind" - existing only in Macbeth's head - but the witches aren't. Banquo sees them too. So is it all Macbeth's fault - and can we draw a moral? The answer to both questions depends totally on how you interpret the play.
We also don't have enough background on Shakespeare as a person to know precisely why any play was written, but it certainly seems as if "Macbeth"'s interest in the supernatural was inspired by James I, recently crowned King of England and himself the author of a book about witchcraft, "Daemonologie". James was also a descendant of Banquo (the historical figure) - hence the witches' prophecy that Banquo's issue will one day reign as kings. So that - at least - might (but only might - we have no evidence) have influenced Shakespeare in the composition of the play.
Another moral of "Macbeth" could be to let nature take its course--don't tempt fate. Shakespeare likes to play with the idea of fate vs. free will. It was prophesied that Macbeth would become king. Macbeth took it upon himself to make the kingship happen, and because of that, he and his wife, among others, ended up dead. It could be argued that if Macbeth has believed in the prophecy, he should have let mature take its course and he would have become king. He believe in the prophecy, but not in the strength of fate to make it happen.
The moral of the story is that power corrupts, and we do have control over our own lives. Macbeth decides that he does deserve to be king, because the witches put the idea in his head. Yet the ambition was already there.
Shakespeare wrote the play to entertain King James I of England and to appeal to his Scottish roots...he is supposedly related to Banquo, one of the few honorable and admirable characters in the play.
One of the morals of the play is "beware of being overly ambitious." It can get you into huge trouble. While ambition is not a terrible trait, going overboard (ie. murder) to get what you want is not suggested.
If 'Macbeth' can be said to have a 'moral' I would suggest that the play principally shows how destructive ambition or over-ambition can be. Macbeth, who seems to be at heart a good man, is led into thoughts and actions that are fundamentally against his nature and lead in the end to the destruction of himself and others, including his wife, Lady Macbeth, who initially encourages him but quickly senses that he will not be able to hold on to what he has wickedly gained.
As for Shakespeare's idea behind the play, very difficult to say. Quite a few of his plays deal with kingship and power and the responsibility that power brings and in this regard 'Macbeth' seems to suggest that when properly established authority is deposed by foul means, dire consequences can follow.
Macbeth at the time was written in reference to James l, however, the moral of the play can also be subjected to ambition in respect to the tradegic hero-Macbeth. There can be many perspectives:
"do not let your ambition control your fate"
"what goes around comes around"
"too much ambition and thirst for power will lead to your ultimate destruction"
Shakespeare wrote the play as a tribute to King James I..