The public saw the plays were fiction, perhaps even a warning against witchcraft, and the magic in them is divorced of religious overtones.
It is noteworthy that the two Shakespeare plays which deal most overtly with magic, Macbeth and The Tempest were both written during the reign of King James I. James was an enthusiastic believer in the dangers of witchcraft and wrote an entire book on it, Daemonologie.
In doing so, he was echoing the beliefs of the majority of his subjects. To them, witchcraft was a real danger. They would have needed no suspension of disbelief to view the magicians in the plays as a genuine menace. But at the same time, they knew the plays were fiction. Shakespeare gives no quarter in portraying the witches as villainous, nor does he provide any "real magic" for people to copy.
In fact, it seems likely he added these elements to his plays specifically to please his new king. While belief in witchcraft was widespread, this era saw the first significant doubts about the validity of witches emerge. Reginald Scot wrote The Discoverie of Witchcraft which argued most "witches" were women with mental illness. James I wrote Daemonologie partly in response to this tract and had all copies of Scot's opposing work burned when he took the throne.
Macbeth thus supports James' belief in the reality of witches. Furthermore, it actually borrows elements of Daemonologie in its depiction of witchcraft. The book discusses the Berwick Witch trials of 1590 which, like the play, took place in Scotland and, like the play, saw the witches accused of raising storms.
Second Witch: I'll give thee a wind.
First Witch: Thou'rt kind.
Third Witch: And I another.
First Witch: I myself have all the other,
And the very ports they blow,
In the trials, the storms were said to be sent against James himself, giving this a particularly personal angle to the King. In fact the line:
Though his bark cannot be lost,
Yet it shall be tempest-tost.
Is thought to refer directly to this incident.
There are further parallels. One of the witches says:
But in a sieve I'll thither sail,
And during the trials, one of the alleged witches was said to have attempted to cross the Firth of Forth in a sieve.
The witches in Macbeth generally behave in a manner similar to that described by King James in his book. He has them dancing at rituals, rifling graves for body parts, stirring cauldrons and performing magic with toads, all of which are mirrored in the play.
So in fact, far from causing trouble by including magic in his plays, Shakespeare was simply conforming to and supporting the prevailing trend and pleasing his new monarch. There was no threat to him in doing so and, to be sure, he was careful never to mention magic in a religious context nor to make his sorcerers into heroes. The nearest he comes to a sympathetic wizard, Prospero, repents and gives up magic at the end of The Tempest, thus saving the playwright from any possible accusation he was portraying witchcraft in a positive light.