The title of William Shakespeare's romantic comedy fantasy, A Midsummer Night's Dream, written in about 1595–1596 and first published in 1600, is derived from a pre-Christian European holiday, Midsummer’s Eve, which was celebrated in June on the night before the summer solstice, the longest day of the year.
The holiday was associated with magic, fairies, and dancing—all of which occur in Shakespeare's play—and bonfires were lit in ancient celebrations of Midsummer's Eve to strengthen the sun, because after the solstice the days grew shorter and the sun appeared to be weakening. The festival occurred early in the growing season, and the celebration of feasting, singing, and dancing is also related to ancient fertility ceremonies which were performed to ensure a successful harvest.
In some European countries, Midsummer's Eve activities also included dancing and singing around a maypole, which is a tall wooden pole set in the ground and decorated with flowers and greenery. A maypole might also be decorated with ribbons, which the dancers weave around the maypole as they dance.
Hermia makes reference to a maypole in A Midsummer Night's Dream when she mocks Helena for being tall (because Helena mocks Hermia for being short) while both of them are vying for Lysander's love.
HERMIA. Now I perceive that she [Helena] hath made compare
Between our statures...
And are you grown so high in his esteem
Because I am so dwarfish and so low?
How low am I, thou painted maypole? (3.2.300–306)
When Theseus, Duke of Athens, finds the four lovers—Hermia, Helena, Demetrius, and Lysander—asleep in the woods outside Athens, he remarks,
No doubt they rose up early to observe
The rite of May (4.1.132–133).
He thinks they did this as a way to celebrate his upcoming wedding to Hippolyta.
Theseus is referring to another Elizabethan festival, May Day, which occurs before dawn on the first day of May and which celebrates nature by people gathering blooming tree branches to decorate their homes. The May Day celebration also included singing and dancing around a maypole.
As far as the "Dream" part of the title A Midsummer Night's Dream is concerned, there's another custom of the celebration of Midsummer's Eve which is that maidens were supposed to dream about their true love that night. Hermia and Helena dream about their true loves that night—although their true loves are mixed up by Puck's botched magic spell—and Lysander, Demetrius, and even Bottom, the weaver, and the fairy queen, Titania, get involved in the dreamlike confusion which is central to the plot of the play.
During the English Interregnum—the period of English history between the beheading of King Charles I in 1649 and the reinstatement of the monarchy under his son, Charles II, in 1660—performances of plays were prohibited, although the performances of acrobats and jugglers were allowed. A section of Shakespeare's A Midsummer Night's Dream, the part about Bottom's dream, appropriately titled "Bottom's Dream," was extracted from the play and presented as a droll, a short comic play or interlude which was performed by acrobats and jugglers to circumvent the laws against the performance of regular, full-length plays.
Puck's final speech to the audience at the end of the play leads some scholars to suggest that the entire play is the dream or a dream-like projection of the imaginations of Theseus and Hippolyta. However, it's also possible he's just asking the audience to pretend it was a dream if they did not like the play.
PUCK. If we shadows [spirits] have offended,
Think but this, and all is mended,
That you have but slumber'd here
While these visions did appear.
And this weak and idle theme,
No more yielding but a dream... (5.1.418–423)
In some productions of A Midsummer Night's Dream, this is shown onstage by having the same actors portray Theseus and Hippolyta, the Duke and Duchess of Athens, and Oberon and Titania, the King and Queen of the Fairies. In this way, Theseus and Hippolyta become part of their own dream.