Dumbledore tells Harry that
"[The Mirror of Erised] shows us nothing more or less than the deepest, most desperate desire of our hearts. You, who have never known your family, see them standing around you. Ronald Weasley, who has always been overshadowed by his brothers, sees himself standing alone, the best of all of them. However, this mirror will give us neither knowledge or truth. Men have wasted away before it, entranced by what they have seen, or been driven mad, not knowing if what it shows is real or even possible."
-Harry Potter and the Philosopher's Stone, Chapter 12
What was the reasoning behind the mirror's creation? What purpose would it serve?