It could be that the balance of factors was weighed right for HAL to resort to murder at the time. Dave and Frank say that, if they restore the original part to let it fail and then figure out what was wrong with it, but it turns out there really wasn't anything wrong with it, then they'd have to disconnect HAL. HAL isn't truly in danger of being deactivated until the old AE-35 is plugged back in, but the moment that that happens, then it's a foregone conclusion he's eventually going to be found out and shut down. So he attacks Frank as he's installing the new unit, but that's also ensured he'll be shut down, so he lets Dave leave the ship, where he can be locked out safely (since Dave is mostly suited up, so he'll be hard to kill if he depressurizes the ship with Dave still inside (which is what happens in the novel, where Dave never leaves to try and rescue Frank, and HAL tries to asphyxiate him), but outside, he can't do much damage without also killing himself), and then once Dave is out, HAL kills the three mission specialists, because they'll also deactivate HAL once they wake up and find out they're out of contact with Earth and their flight crew has been missing for months and put two and two together.
It's a little Asimov-y that HAL needed to wait until his reason to kill passed some mathematical threshold (I'm thinking of the story of the robot that ended up circling around a dangerous radiation source indefinitely, because that was the exact point where the danger to itself from approaching and the intensity of the order given to approach it balanced, and to advance was to put it into unacceptable danger, but to retreat was to defy orders for an unjustifiable reason), but, well, they were contemporaries.