The Queen Mab speech, delivered in Act I, Scene 4 by Mercutio serves three purposes. First, it introduces the audience to Romeo's colorful and volatile best friend. His fantastical speech is full of amazing imagery as he weaves a tale of the "fairies' midwife" (originally from Celtic mythology) who travels into people's brains and makes them dream. At first the speech seems to be a simple improvisation meant to entertain the Montague men as they head to the Capulet party. He talks of a minuscule fairy who rides around in a "chariot" made from "an empty hazelnut." She makes lovers dream of love and lawyers dream of money. It is an endearing fantasy at first, but then it turns dark and edgy as Mercutio claims that this same "Queen" is also a vicious "hag" who "blisters" the lips of promiscuous ladies and makes soldier's dream of "cutting foreign throats." The speech does an excellent job of introducing Mercutio as witty and lighthearted but also as someone with an intense nature who could be pushed to violence.
Second, the speech is Mercutio's way of telling Romeo to snap out of his dreamy love for Rosaline. By claiming that dreams are "children of an idle brain" he is suggesting that all of Romeo's "groaning for love" is childish and beneath him. Mercutio looks at love realistically and believes Romeo is acting foolishly in his obsession with Rosaline. Above all, Mercutio wants Romeo to move on and have a good time at the party.
Third, the speech reinforces the dichotomy within the play. On one hand, Mab is a harmless entity who brings fantasy fulfillment to those she makes dream. But, on the other hand, she is malevolent and evil as she induces dreams of violence in the unconscious minds of soldiers and forces nightmares on young virgins ("maids"). This same dichotomy can be seen in Friar Laurence's speech at the beginning of Act II, Scene 3 when he declares that "within the infant rind" of a flower is the power of medicine but also the ill effects of poison. He likens the flower to the souls of men who have the ability to do great good but are also capable of destructive evil. These elements pervade the tragedy as good people commit heinous acts of violence. Tybalt (obviously loved by his family) is driven by his code of honor which ultimately brings his death. Mercutio is driven by arrogance and intensity. Romeo too, becomes the vehicle of evil as he seeks revenge on Tybalt and then kills Count Paris in a fit of madness outside Juliet's tomb. Queen Mab, then, is a symbol of both good and evil which parallels the motives and actions of the main characters in Shakespeare's plot.