It works on the basis of reports from hospitals, and keeps information (like name, ID number, age and gender) for every deceased person. A lot of that information can actually be verified by Israel, since Israel controls the Gaza population Registry. If these people later showed up alive, that would easily prove the Health Ministry is lying. Yet that hasn't happened.
After past conflicts, outside organizations have reviewed the Health Ministry's numbers, and have determined them to be accurate, which is why major news organizations consider it reliable.[0] Even the Israeli government privately considers the numbers to be reliable and uses them in internal discussions, though it publicly claims them to be unreliable (the reader can guess why). Israeli intelligence has surveilled the Health Ministry, and came to the conclusion that it was working in good faith.[1] Again, this is completely different from what the Israeli government says in public.
The Gaza Health Ministry has periodically released its entire list of verified deaths. You can read every person's name, age, etc.[2]
The main concern about the numbers is that they are probably a massive undercount. Every hospital in Gaza has been bombed by the IDF, and the healthcare system is barely functioning at all any more. Beyond that, there is rubble everywhere, and nobody knows how many people lie dead underneath it.
0. https://www.washingtonpost.com/world/2023/10/24/gaza-death-t...
1. https://www.mekomit.co.il/%d7%94%d7%a6%d7%91%d7%90-%d7%91%d7...