We never find out because Harry never asked. He meets Moody as a teacher, and finds him quite intimidating at first.
...it was the man's eyes that made him frightening.
The Triwizard Tournament, GoF
...he entered the room, looking as strange and frightening as ever... it was nevertheless a relief to know that he ever did anything as friendly as smile.
The Unforgivable Curses, GoF
They're not on their own together that much, or not in circumstances where he'd be likely to ask about the eye (on the stairs in the middle of the night; after he's come out of the maze).
There are a few more opportunities in OoTP at Grimmauld Place, but Harry doesn't actually know
the real
Moody that well. There's also a lot going on — he doesn't see him often, and isn't as relaxed around him as he is with some of the other adults. When Moody calls him over for a conversation and shows him a photograph of the old OotP Harry finds it upsetting
well, Moody might find that interesting... he, Harry, found it disturbing...
The Woes of Mrs Weasley, OotP
and makes an excuse to escape talking to him.
Also (possible speculation), Harry is usually pretty polite. He does know that it was presumably lost duelling a dark wizard, and maybe thinks that's enough. Asking somebody what caused their injuries isn't really the done thing — you'd generally wait until somebody trusts you enough to tell you that information, or at least until it was raised in conversation.
Out of universe, presumably because JKR didn't think knowing would add much to the story, which is really about Harry.