Clarke addressed this question directly in his sequel "2010", in which Dr Chandra describes Hal's descent into madness as a "Hofstadter-Moebius loop", in which a lie from a trusted authority figure (the US government) contradicted HAL's instructions from another trusted authority, the crew, which introduced an insoluble logical impasse, resulting in a breakdown in HAL's executive function -- a homicidal level of frustration.
https://en.wikipedia.org/wiki/HAL_9000#2010:_Odyssey_Two