Question: why did pyle kill hartman?
Answer: Pyle's weakened mental and emotional state, coupled the effects of the blanket party and his confrontations with his drill sergeant led to a complete mental collapse and this triggered the events leading to his suicide. In short, he kills himself because he's lonely.