Here's how it happened:
1. He heard a rumour: Harry heard from other students about a mirror in the forbidden room that showed your deepest desires.
2. Curiosity got the better of him: Despite the warnings, Harry's curiosity overcame him, and he decided to find the mirror.
3. He found the room: Using a map that he found in the library, he found the room and the mirror within.
4. He looked into the mirror: Harry was captivated by the mirror and saw his parents alive and well, something he had always longed for.
So, Harry didn't discover the mirror in the sense of inventing it or finding it in a secret place. He found it in a place known to others, but forbidden to him because of its powerful and potentially dangerous nature.