This expression is a shortened version of one of any number of other expressions often used during times of consternation. Such expressions include:
"I'll be hornswaggled."
"I'll be a monkey's uncle."
"I'll be damned."
The final item in this list is also the most common, being the simplest, and it is probably the expression that caused the evolution of the shortened form. In polite society it is usually considered rude to curse publicly, so an expression of surprise following the "I'll be damned" idiom was made necessary. "I'll be" is the product of this vacuum, being an expression that follows the aforementioned idiom but does not include curse words. It might be said that the other, sillier expressions regarding primate lineage and nonsense words are similarly derived by substituting something less offensive in place of cursing.