A good question. When asking the "why" question, sometimes it is useful to ask it directly, but sometimes we get more/better answers by asking things like, "What purpose does the fifth act serve?"
One reason for this is that a main reason the fifth act exists is tradition. Look at the different plays Shakespeare wrote: Hamlet, Lear, Twelfth Night…they are very different, but they all have fifth acts. It's a standard form.
Now, if we ask what purpose the fifth act serves, we get different and perhaps more useful answers. The fifth act wraps things up. It resolves all plot questions.
It also provides a kind of balm. The two pairs of lovers have been through experiences that would be pretty hellish if real (loving one person, then another, lost in the woods, etc.). This shows them happy, laughing, etc. It shows they weren't hurt.
Adding the rude mechanicals allows humor, and provides several different kinds of perspective on the play. It shows another blocked love affair (one that ended badly), another kind of play, and another kind of spectatorship.
There has always been 5 acts to Shakespeare's plays in general. For example, Romeo and Juliet has five acts. The fifth act is called the resolution or denouement.
This is the conclusion to the overall story.
So in "A Midsummer Nights Dream", the fifth act is the ending or conclusion.
The inclusion of the fifth act to the story was actually to provide humour and a joyful comic epilogue to the end of the play by adding the craftsmen’s funny bungling tries in their act and the Athenians’ jesting during the act.
It also ties up loose ends to any unanswered questions and fill up the loopholes or lingering doubts about the story. It also provide a soothing sensation towards the pair of tragic lovers as they had to suffered a lot of hardship and troubles that it is very hellish, making the whole problem come into peace and calmness, like tranquility