He resigned because he understood that Trump and other Republicans were going to take over in 2024,and someone who had once been beaten in a reelectoion has zero chance of ever getting the party backing or nomination again.
Better to quit now and then run again when the conditions are more favorable for him.