He likely thought his job was pretty secure, having met with President Elect Trump. He decided to be a wise guy and show how much he held to the letter of the law (if the President is not supposed to communicate with the DOJ lawyers) and got a big surprise. After hearing this was the guy who prosecuted Dinesh D’Sousa, I’m glad he’s out.
The law? Sounds unconstitutional. Congress doesn't manage the executive branch, the president does.