The answer is simple.
The HAL9000 was a very sophisticated computer...but a computer nevertheless. He sang that song because, at some point, he was programmed to do so.