A Midsummer Night's Dream by William Shakespeare actually has two separate settings. The first setting is ancient Athens in the time of Theseus. In the Elizabethan period, scholarly chronology of antiquity was, at best, imprecise. Theseus would have been placed in an early heroic period, perhaps slightly before the Trojan war. Because this setting is far from the reality of Elizabethan England, it allows Shakespeare scope for imagination and flexibility in handling issues like customs and mores; two upper class girls in England running off and spending time sleeping in the woods with two young men would have ruined their reputations for chastity and become unmarriageable.
The wood is a fantastical setting, filled with magic. It is a world of dreams, and perhaps a dreamscape rather than a reality. It is a place of mysterious beauty where wishes can be made true and fantasy become reality. It gives the play its mood of light fantasy and allows a magical solution to the romantic problems of the love plot.
This play uses two different setting locations. The play begins and ends in ancient Athens. More specifically, readers are told at the beginning of Act I that the play opens in the palace of Theseus. The second setting to this play is a forest "near Athens."
The two locations definitely affect the mood of the play. Athens is ruled by law, order, and logic. It's a place of great seriousness. It is so serious a place that a father demanding the death penalty for a daughter's disobedience isn't terribly odd.
Contrast that serious and not fun mood with the mood that is established in the forest setting. The forest is a place of great mystery and magic. Fairies live there, and they are not governed by law, order, and logic. Instead, they are governed by their emotions. A good example of the forest's "do as you feel" mantra is in how Titania and Oberon interact with each other. They plot and scheme against each other one moment only to quickly change their minds and forgive each other the next moment. The reason for the attitude change isn't logical; it's simply because their mood has changed. Problems and arguments can be, and are, laughed away as whimsical fun. It gives an overall lighthearted mood to the forest sections.
As for how the two locations affect the plot, the forest offers the four young lovers a place to cavort with each other away from the prying eyes of the overly legalistic Athens society. Because it's a magical forest, the actions of the characters can be laughed away and forgiven. Additionally, because it's a magic forest, new solutions to the ridiculous love triangles can be figured out.