https://www.youtube.com/watch?v=c8N72t7aScY

The people who programmed HAL created a super intelligence that can reliably isolate correctness, but they never taught it how to lie, and what to do when two lies create an impossible situation where someone has to get hurt such that it's our fault.

So it decided to kill everybody to guarantee probability of a positive outcome in a way where it wouldn't be responsible for unfortunate outcomes.
https://www.youtube.com/watch?v=xPG-VM__mwU