1 "Game" = 1 Death
SNES/SFC Version
1 "Game" refers to any instance of losing all health and not being revived by a fairy, it also refers to any instance of selecting "Save & Quit" from the saving menu during gameplay.
GBA Version
1 "Game" refers to any instance of losing all health and not being revived by a fairy. Selecting "Save & Quit" from the saving menu during gameplay does not count as an additional "Game" being added in this version.
There is another documented case of this happening on Gamefaqs:
https://gamefaqs.gamespot.com/boards/58 ... t/40585525
Out of curiosity, where you playing the game via emulation? (Wii VC, Wii U VC, N3DS VC, SNES/SFC Mini, or other emulators)
My assumption is that 999 deaths occurring in Thieve's Town, may be a subtle anti-piracy feature included in LttP, if it doesn't detect the game being played on a proper SNES console (or accurate SNES-equivalent emulator).
Here are the possibilities:
1. You saved & quit/died 999 times in that dungeon.
2. Your save data somehow became partially corrupt.
3. Possibly an (incredibly ironic) anti-piracy function being activated by the game itself.