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.