In the 2004 senate election, Obama was pitted against Jack Ryan. In the middle of the campaign, papers were released as part of Ryan's divorce that suggested he had taken his wife to sex clubs and asked her to have sex in public. Moreover, he had lied privately to the Republican committee, saying that there was nothing potentially embarrassing in the divorce files. As a result, Ryan lost the support of his party, and without support was forced to withdraw.
Keyes was brought in. Keyes had not even been in the primary campaign. Keyes had no connection to Illinois. He had no name recognition in Illinois. His previous criticism of Hillary Clinton standing in New York was used against him. He was outspent by Obama by a factor of about 7:1. And he made mistakes on the campaign trail, suggesting that Obama was not a true African-American. Moreover Keyes's conservative and hard-line policies on abortion, for example, did not go down well with the generally moderate republicans in suburban and rural Illinois.
In other words, this was a disastrous campaign for the Republican Party. Obama, on the other hand, fought a smart campaign. He stayed above the fray while the Ryan campaign imploded. He used the gap when the Republicans had no candidate to campaign amongst moderate Republicans and build name recognition. He made no mistakes and appeared calm and confident candidate.
There was notable split-ticket voting in 2004. With Kerry winning the state by (only) 10 percentage points, and many rural counties voting for Bush in the presidential election, but Obama in the Senate.