New from j.k. rowling the mirror of erised
The Mirror of Erised is a very old device. Nobody knows who created it, or how it came to be at Hogwarts School. A succession of teachers have brought back interesting artefacts from their travels, so it might have arrived at the castle in this casual manner, either because the teacher knew how it worked and was intrigued by it, or because they did not understand it and wished to ask their colleagues' opinions.
The Mirror of Erised is one of those magical artefacts that seems to have been created in a spirit of fun (whether innocent or malevolent is a matter of opinion), because while it is much more revealing than a normal mirror, it is interesting rather than useful. Only after Professor Dumbledore makes key modifications to the mirror (which has been languishing in the Room of Requirement for a century or so before he brings it out and puts it to work) does it become a superb hiding place, and the final test for the impure of heart.
The mirror's inscription ('erised stra ehru oyt ube cafru oyt on wohsi') must be read backwards to show its true purpose.
J.K. Rowling's thoughts
Albus Dumbledore's words of caution to Harry when discussing the Mirror of Erised express my own views. The advice to 'hold on to your dreams' is all well and good, but there comes a point when holding on to your dreams becomes unhelpful and even unhealthy. Dumbledore knows that life can pass you by while you are clinging on to a wish that can never be — or ought never to be — fulfilled. Harry's deepest yearning is for something impossible: the return of his parents. Desperately sad though it is that he has been deprived of his family, Dumbledore knows that to sit gazing on a vision of what he can never have, will only damage Harry. The mirror is bewitching and tantalising, but it does not necessarily bring happiness.