Shakespeare (and his company of Chamberlains Men) relied heavily on Royal 'acceptance'. While the theatre was still considered to be of low status, having to perform on the less desirable side of the Thames, along with the bear baiters and other leud activities. The constant threat of being shut down bore heavy on the heads of playwrights. Under Elizabeth I, Shakespeare experienced great success and popularity in the Royal Court.
When Elizabeth I died without an heir, naming James VI as her successor (to become James I of England and Scotland), Shakespeare was keen to present his best side forward to impress the new monarch.
James was a well known lover of performance, and a believer in Witchcraft. Persecution of witches in Scotland began during his reign, and he even wrote a book entitled "Daemonoligies" about witchcraft, asserting how real a threat witches were.
Shakespeare wrote MacBeth in a very short time, specifically to the tastes of the new King. He wrote about the manipulation by witches, set in Scotland, and filled with the information for a watching crowd that killing a King is always wrong. James I became a fan, and Shakespeare was to continue to rise in success under the name of "The Kings Men".