He lost his job because he did something stupid and the people who wanted him gone took advantage of it to get rid of him. It’s that simple.
He lost his job because, in typical Bush Administration fashion, he was incredibly naive about the lengths to which his enemies would go to destroy him.