In addition to the knowledge of the times included above, concerning Macbeth specifically, Shakespeare wrote it at least in part with King James I, of King James Bible fame, in mind. That's probably why Banquo is depicted as such a hero and a good man in the play--King James really was a descendant of Banquo.
Shakespeare appears to have had James in mind when he gave such prominent roles to the witches, as well. James was fascinated with witchcraft. I don't have first-hand knowledge of the writings, but one British Literature text that I have says James even wrote attacks against witchcraft, until one day when a witch, upset with him, revealed information to him about his past that no one else could have known. I don't know if this is true or not, but the idea that James was fascinated with witchcraft is well accepted.
Thus, Shakespeare, at least in part, wrote to interest and please the king.