Barack Obama had that unique appeal to the masses like what we saw in Zohran Mamdani in NYC, even if Ditka ran against Obama, Obama would still have won in '04.
The only way he would have lost is that if he was involved in some scandal.
Obama was in the right place at the right time. 2008 was the start of a financial crisis where the Republicans were blamed. He could have beaten anyone.
He also faced two pretty weak candidates, McCain and Willard. Interestingly, Obama’s re-election was the first one in modern history where his margin of victory was SMALLER than his initial election.