I believe the preference is there so that someone actually going through an election is first vs an appointment.
President
VP/President of the senate
Speaker of the House
Then cabinet....though I suppose if the speaker died and a new speaker were appointed they would take precedence before the cabinet first....it’s all a matter of timing
Forgot about that, too. Given that our election process is soooo pure the last several decades. /sarc sigh