Why did all the people on board have to die for Kirk to be right?
The issue here is two-sided. The M5 side of the argument is covered above. The other side is that Kirk painted himself in a corner of sorts by asking M5 whether there is "life" aboard the ship. If M5 says "yes", then this does not
conveniently lead to the conclusion that M5 has committed murder. Sure, it has decreased the number of lifesigns, but the answer of "yes" does not make it feel pangs of guilt like an answer of "no" would.
Why does Kirk ask in terms of absolutes? He has no way of knowing whether there are survivors aboard the ship, apart from his professional expertise. Perhaps he knows that the types of hits M5 scored are lethal to the entire crew, even though nowhere else in Star Trek do we witness phasers having such an effect on an unshielded ship?
So there are two reasons to think all lives were lost - the wording chosen by Kirk, and the failure of M5 to talk back. But there are two reasons to think the opposite - the failure of Wesley to indicate anything of the sort, and the lack of mechanisms by which M5 could have achieved the result.