HAL was told to lie.
That’s what they said in the later 2010 movie. But in the 2001 movie, it looked like Hal went nuts because his simulated emotions made him prideful of his own perfection. So when he got caught making a mistake, he couldn’t handle it and killed all the witnesses to cover it up.