Sleep serves the purpose in Act 4 of creating resolution and enlightening the characters, but also of further confusing the characters.
In Act 4, both Bottom and Titania fall asleep. While asleep, since Titania has finally capitulated and given Oberon the Indian foundling, Oberon decides to relent and remove the love spell from Titania's eyes. Oberon uses a flower he refers to as "Dian's bud" as the antidote to the love spell, which makes sense because Diane is the Roman goddess who is known for her chastity (IV.i.72). The direct result is that Titania becomes repulsed by the man with the donkey's head and flies around the globe with Oberon in unity, asking him to explain to her how the occurrences of that night came to pass. Since Titania's and Oberon's argument has been resolved, we can say that the role sleep plays is to resolve their issues and create unity.
Similarly, Puck is commanded by Oberon to remove the donkey's head from Bottom and to make sure that all the members of both the Athenian couples wake up in love with the right person, as we see in Oberon's lines:
And, gentle Puck, take this transformed scalp
From off the head of this Athenian swain,
That he awaking when the other do
May all to Athens back again repair,
And think no more of this night's accidents
But as the fierce vexation of a dream. (IV.i.63-68)
Bottom and the couples do indeed wake up repaired. Bottom is back to normal, Lysander is back to being in love with Hermia, and Demetrius is rightly in love with Helena, whom he was engaged to before he began pursuing Hermia. However, while all the Athenians are at peace, they also remain troubled because they feel that what they had experienced was a dream, but they are also aware that it was not a dream, which leaves them in a very confused state of mind. We see the two Athenian couples being confused about their dream state when, after seeing Theseus and Egeus, they ask each other if they are still dreaming, as we see best in Demetrius's lines, "Are you sure / That we are awake?" (185-196). Their state of confusion even remains when in the fifth act they relay the exact same account of what happened to them, as we see in Hippolyta's lines:
But all the story of the night told over,
And all their minds transfigured so together,
more witnesseth than fancy's images. (V.i.24-26)
In other words, Hippolyta is pointing out that because they are all giving the same account of the story, their story bears witness to the fact that they did not imagine what happened to them.
Bottom also wakes up with the same sort of confusion. On the one hand he wakes up believing that he had been dreaming, as we see in his lines, "I have had a most rare vision. I have had a dream" (IV.i.208-209). But he also believes that he truly has seen himself in the form of a donkey and having had donkey ears.
Hence we see that while the purpose of sleep is to create resolution for the characters and the story line since it is during sleep that the spells can be cast, we also see that waking up from sleep also creates confusion for the characters.