Perhaps he might want to care less about his perceived credibility (if such is the case) and more about the US as a whole. And as I see it, this move doesn't really do his credibility any favors anyway, except if you're in the Trump detractor crowd and somehow see this as a way in which to further bag on the POTUS.
Either you think this resignation is good for the US, or you don't. Which is it?
I don't know.
When Mattis was announced for this position, the people with more experience than me (left and right) said this was a great appointment because of Mattis' skills, knowledge and character.
When Mattis announced his resignation, he made clear it's because the administration is taking a very different approach to our alliances than he thinks we should and he can't be a part of that. A man praised for his skills, knowledge and character thinks we're taking the wrong direction.
On one hand, it's good for the Sec. of Defense to align with the WH on foreign policy direction. On the other hand it's extremely bad when the person who was considered extremely credible for the position says the administration is taking the wrong direction to such a degree that he can't continue to participate.
People need to stop shifting things into "bagging on the POTUS" vs. "not bagging on the POTUS". Sometimes people are doing a bad job. Blindly defending them is just as bad as blindly attacking them. Once you get past the rhetoric, you have to start measuring what is actually being done.
You can agree with reducing illegal immigration and still have a problem with unconstitutional means of doing so. You can think taxes are too high and still have a problem with ballooning the deficit to pay for tax cuts. You can think border security is a good idea and still think $5B for a wall is a waste and that a wall is not a good reason for a government shutdown.
Good intentions mixed with bad implementation is still a shitty job.