When the witches first appear in William Shakespeare's Macbeth, the role they play is to set the scene for the play, introduce some suspense—"When shall we three meet again?" (1.1.1)—draw attention to Macbeth, and lend a supernatural tone to everything that follows.
Some scholars believe that Shakespeare wrote Macbeth, and included the witches in particular, to solicit the favor of King James I, who ascended to the throne of England in 1603 after the death of Queen Elizabeth I. While he was King James VI of Scotland, before becoming King James I of England, James displayed a notable interest in demons and witchcraft. He organized notorious "witch hunts, " personally conducted interrogations of suspected witches, and attended witch burnings—some of which were no doubt the result of his own "witch hunts" and interrogations.
In 1597, James I wrote a treatise about demons and witches entitled Daemonologie, first published in 1597 in Scotland. James had the treatise republished in England in 1603 after he became King of England. Shakespeare very likely read it, since he lifted some of the elements of witchcraft in Macbeth directly from Daemonologie, including the ingredients of the famous cauldron in act 4, scene 1, "Round about the cauldron go:/ In the poison'd entrails throw," and the belief that witches could fly and that they were invisible while they were flying through the air.
BANQUO. Whither are they vanish'd?
MACBETH. Into the air, and what seem'd corporal melted
As breath into the wind (1.3.83–85).
In any event, the witches in Macbeth aren't Shakespeare's invention; they predate Shakespeare and King James by a few millennia. The story of the witches appearing to Macbeth and making prophecies to him occurs in Raphael Holinshed's Chronicles of England, Scotland and Ireland, which recounts Macbeth's reign in the 11th century.
It fortuned as Macbeth and Banquo journeyed towards Forres ... met them three women in strange and wild apparel, resembling creatures of elder world ... the first of them spake and said, "All hail Macbeth, thane of Glammis!" ... The second of them said, "Hail Macbeth thane of Cawdor!" But the third said, "All hail Macbeth that hereafter shalt be king of Scotland" (Chronicles, Vol. 5).
Aside from that, Shakespeare's acting company, known as The Lord Chamberlain's Men during Elizabeth I's reign, were made The King's Men in 1603 by royal decree when King James I ascended the throne and became the company's patron. Shakespeare and eight other members of the acting company even participated in James I's coronation procession.
Shakespeare didn't write Macbeth until 1605–1606, long after James I assumed the patronage of Shakespeare's acting company. It's more likely that Shakespeare wrote Macbeth as a "thank you" for James I's patronage than as a solicitation for his favor. Shakespeare didn't have to solicit James I's favor; he already had it.
The second time that the witches appear in Macbeth, in act 1, scene 3, they make prophecies to Macbeth and Banquo, and these prophecies arouse Macbeth's ambitions to be King. There's nothing in the scene to indicate that the witches have evil intent in making these prophecies. At the beginning of the scene, the witches are discussing witch things like "killing swine" (1.3.2) and a severed "pilot's thumb" (1.3.29) that have nothing to do with Macbeth. They don't even mention Macbeth until they hear drums announcing Macbeth's entrance in the scene.
During the scene with Macbeth and Banquo, the witches waste no time making their prophecies, and then they disappear, witch-like, "into the air" (1.3.84). Macbeth wants them to stay to explain the prophecies, how they acquired the knowledge of the prophecies, and why they're making these prophecies to Banquo and himself at this particular time. Macbeth gets no answers to his questions, and neither does the audience.
It's not until much later in the play, in act 3, scene 5, that the audience can gain any insight regarding the witches' motivation for making the prophecies. Even then, the motivation for the prophecies isn't revealed by the witches themselves, but by Hecate, the goddess of witchcraft and the three witches' boss, who scolds the witches for involving themselves "In riddles and affairs of death" (3.5.5) without her.
Not only that, says Hecate, but the witches involved themselves in Macbeth's affairs without evil intent.
HECATE. And, which is worse, all you have done
Hath been but for a wayward son,
Spiteful and wrathful: who, as others do,
Loves for his own ends, not for you (3.5.10–13).
The rest of Hecate's speech, in which she gives reasons for making the prophecies to Macbeth, seems misplaced, coming so late in the play as it does. Hecate goes on about how she's going to
raise such artificial sprites
As by the strength of their illusion
Shall draw him on to his confusion (3.5.27–29).
By now, however, the damage has already been done. Macbeth has risked everything to murder Duncan and usurp his throne, and he's ordered the death of Banquo, whose ghost recently appeared, uninvited, at Macbeth's coronation feast.
Hecate's speech seems misplaced because the scene was later added to Macbeth, and Shakespeare probably didn't write it. Thomas Middleton is the most likely author of this scene, because of its remarkable similarity to scenes in Middleton's appropriately-titled play The Witch. Middleton probably also contributed Hecate's other appearance in Macbeth, in act 4, scene 1, which serves no purpose in the play whatsoever.
Hecate's speech doesn't belong in this scene, or anywhere else in the play for that matter, because it simply confuses the witches' role in the play.
It appears as if the three witches' involvement in the play begins innocently enough—innocently enough for witches—with the witches making prophecies to Macbeth and Banquo for no particular reason, except perhaps to amuse themselves, for which Hecate calls them to task in act 3, scene 5. With the arrival of Hecate, however, the witches are reminded of their essential role with regard to their dealings with humanity, and the whole witch business in the play turns sinister.
The newly-sinister intentions of the witches appear to be played out in act 4, scene 1, the "apparition scene" when the apparitions give Macbeth equivocal information—even more equivocal than the initial prophecies—that Macbeth accepts at face value, as Hecate said he would.
HECATE. He shall spurn fate, scorn death, and bear
His hopes ’bove wisdom, grace, and fear (3.5.30–31).
The witches instigate Macbeth's great adventure by arousing Macbeth's ambition to be King with their prophecies in act 1, scene 3, then facilitate and insure Macbeth's ultimate self-destruction through the words of the apparitions in act 4, scene 2.