He was only planning to take the job for a year. He would have left at the end of book 4 anyway. Besides, once the Order was reformed, they really needed Moody on the front lines.
Technically, the law that allowed them to force Umbridge only came into effect when Dumbledore wasn’t able to find a replacement himself. That’s why Dumbledore was able to stop them from putting another ministry stooge in Trelawney’s place by hiring Firenze.
Either way, moody being stuck in the trunk for a year would not make him eager to actually teach the next year, and he was planning on only doing so for a year, plus the order of the Phoenix
Tactically, Hogwarts was only important because of Harry, and there were several other Order members there to protect him. Moody was probably more focused on protecting the prophecy. I don’t know why Dumbledore couldn’t just hire Daedulus Diggle or somebody though.