Doughnut is the original and correct way of spelling it. The earliest occurrence of the word is in the work of Washington Irving (1809). He had to define the word, so we can assume that it was not a widely known dish at the time, at least to his audience. And, interestingly, he defines doughnuts as "balls of sweetened dough, fried in hog's fat". This suggests that doughnuts were not named after knots or nuts and bolts, but instead after nuts like walnuts or pecans. They were balls of dough that, when fried to a deep golden brown, resembled nuts. Doughnuts only took their torus shape to overcome a problem inherent in balls of dough - uncooked centers. Removing the centers ensured that the doughnuts would be cooked throughout.
The first known printed use of donut was in a Los Angeles Times article dated August 10, 1929. There, Bailey Millard jokingly complains about the decline of spelling, and that he "can't swallow the 'wel-dun donut' nor the ever so 'gud bred'." The interchangeability of the two spellings can be found in a series of "National Donut Week" articles in The New York Times that covered the 1939 World's Fair. In four articles beginning October 9, two mention the donut spelling. Dunkin' Donuts, which was founded in 1948 under the name Open Kettle (Quincy, Massachusetts), is the oldest surviving company to use the donut variation, but the now defunct Mayflower Donut Corporation appears to be the first company to use that spelling, having done so prior to World War II.