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.
I don’t think he could’ve kept teaching even if he wanted to; Fudge had kind of forced Umbridge on Dumbledore.
Fudge forced Umbridge on him under Education Decree number 22.
”Educational Decree Number Twenty-Two was passed, to ensure that, in the event of the current Headmaster being unable to provide a candidate for a teaching post, the Ministry should select an appropriate person. ‘That's how Dolores Umbridge came to be appointed to the teaching staff at Hogwarts,’ said Weasley last night. ‘Dumbledore couldn't find anyone so the Minister put in Umbridge, and of course, she's been an immediate success —"
If Dumbledore had appointed Moody or somebody, Fudge wouldn’t have been able to force Umbridge on him without writing up another law.