"Barnburner" had a considerable history before it came to mean an exciting and hotly contested sporting event. It first appeared around 1810 as a slang synonym for "radical," apparently in allusion to a parable in which a shortsighted farmer burns down his own barn in order to drive out the rats living within. "Barnburner" was most notably applied in the years leading up to the Civil War to radical abolitionist members of the Democratic Party who were said to be willing to "burn down the barn," to destroy their party, in order to rid it of pro-slavery "rats." This "cut off your nose to spite your face" sense of "barnburner" is now obsolete.
An entirely different sense of "barnburner" appeared around 1934, meaning "something excellent or very exciting." Barn fires are, of course, one of the worst calamities that can strike a farmer, but they are also usually quite spectacular, and "barnburner" probably derives from the excitement caused by such an awesome conflagration.
Ironically, "barnburner" in the "exciting" or "extremely good" sense was first used in that most un-athletic of games, bridge, to mean a very good hand of cards. From there it spread to encompass anything that "takes off" to become excellent or very exciting, from a basketball game to a political campaign