The play is set at summer solstice: a date that marks the transition of spring to summer. It was believed in Shakespeare's time that the shifts of the seasons were magically potent times when the veil between the worlds (the human world and the underworld) became thinner: hence the humans and fairies can interact more closely at this time. This is a pagan theme that lends a sense of pastoral whimsy to the story. Magic is equated with love, and the fairies use magic to play with the emotions of the human lovers.
The presence of the fairies, while they can be capricious and mean-spirited at times, lends a sense of mystery and ethereality to the play. The humans are often at a loss to explain their actions because they have been the targets of magic: as when Bottom is turned into an ass, or the four lovers' loyalties are challenged when fairy dust is sprinkled on their eyes. When Titania, herself a magical creature, is also affected by the magical fairy dust put in place by Robin Goodfellow, the sense of magic and mysticism is intensified all the more, as it is suggested that even a supernatural being can be affected by the magic of love and lust.
By putting in the use and presence of magic in A Midsummer Night's Dream by Shakespeare, plots often get twisted and go to different directions that we would expect without the presence of magic. For example, the magic flower (potion?) that caused the queen to fall in love with an ass shows the humour and mysticism in that the outcome is difficult to expect.