Macbeth is essentially a play about rebellion and the price of disorder. It is a deeply conservative play, a reactionary attack upon the enemies of kingship dressed up as a poetic mediation upon the pathology of evil. As with all classic tragedies, theatre is used to purge anti social feeling and so reinforce the status quo.
In the summer of 1606, Shakespeare sat contented as King James I, rapt with awe, watched Macbeth. Shakespeare had much wanted such a reaction from the King, who was well known for falling asleep during plays. Indeed it is said that his very purpose for writing Macbeth was most likely to be to honour the new King from Scotland. The Tragedy of Macbeth was based in legend, a story that James had been told repeatedly during his childhood, because of his own direct link to the story (James was one of Banquo's foretold descendants to sit on the throne of Scotland). Shakespeare wrote Macbeth in full consciousness of these facts, knowing that writing a play that had personal connections to James, and which promoted negative feelings toward rebellion and disorder, would put him in good favour with the King.
It is not only the Kings historical affiliation with the play that hints at Macbeth being written as a form of propaganda promoting peace and order. King James had personal ties with Shakespeare himself. As King, one of James" first acts was to take over Shakespeare's company and to promote them to be his own servants, so that henceforth they were known as the King's Men. They acted very frequently at Court, and prospered accordingly. It was in Shakespeare's interest to write a play that would appease James and advocate his Kingship.
Perhaps of the most important pieces of evidence from a contextual perspective, supporting the above theory, are some of the events that took place during James reign. Indeed many of the events that occur in the play have a direct correlation to James.