Christine O'Donnell's success depended upon an alignment of factors. Here's a partial list:
Timing. The Tea Party Express swept in at the right moment. They had just enough of a lead time to build up support for O'Donnell but before other facts about O'Donnell could enter the public narrative. Castle might have begun reversing the momentum, but it wasn't enough.
Hopes of a wave. Many conservatives feel empowered in the current environment. This empowerment hurt Castle in two ways. Many conservatives felt as though they could take a loss in Delaware and were willing to risk it on O'Donnell. They also felt as though a wave of public anger could indeed propel O'Donnell into the Senate and restore the GOP to "purity."
Too harsh, too late. The Castle people delayed going after O'Donnell. This delay caused them to have to go after her fiercely in order to be heard in the waning days of the campaign. These attacks were interpreted as too nasty and allowed O'Donnell to portray herself as a victim, a role she gladly took on. With more time, the Castle people might have shifted the media narrative back in their favor. Meanwhile, O'Donnell's supporters launched an all-out attack on Castle, assailing his record and his personal integrity.
Popular alienation. Voters are very unhappy with incumbents, and Mike Castle was an incumbent's incumbent. O'Donnell cast herself as an avatar for wrath against the establishment, and this gambit worked. Castle cast some high-profile votes against certain conservative dogmas, and he paid the price for them in this race. The state GOP's involvement often wasn't helpful in this regard, as it made Castle appear even more "establishment."
A slow cycle. If this race was held earlier in the primary cycle, Castle could have more easily gotten by. O'Donnell depended heavily upon massive national media attention, and this race would probably have gotten lost in the noise of other primaries.
A closed primary. This would have been a completely different race were it an open primary where independents could make their voices heard.
In any case, if the GOP is to have even the slightest hope of keeping this seat, Mike Castle will have to reconcile with O'Donnell and try to send some moderates her way.