He's forced to by Law.
If the President asks a Active-Duty military officer to take a cabinet position, he has to as if he's following direct orders from a superior.
Only a retired officer can refuse a request by the President.
He also probably sees it as his duty to try to stick his tiny rudder in the water to try to steer this full-steam-ahead disaster of a presidency in any way he can, even if it siphons the life from his soul to do it.