why did Shakespeare write macbeth??what was the purpose behind it
Macbeth wrote the play primarily because he was commanded to by King James I, thus the term "command performance." Before reigning as King James I of England, he was known as James VI of Scotland. Thus, a play set in Scotland and giving battle victory in Scotland would appeal to him. In addition, the truly good character, Banquo, is modeled afer an actual relative of James, making his family look true and continually virtuous in the midst of all the betrayal around him. He does not succumb to the witches prophecies as Macbeth does, thus preserving the family integrity.
More generally, Shakespeare wrote about the common man and his problems. Ambition, greed and betrayal are unfortunately common to most readers, keeping the interest in this play alive for generation upon generation.