I just found myself using the phrase “I’ll bet you dollars to donuts that. …” I wasn’t really betting anything. But eventually my brain said, “Dollars to donuts? Where’d that come from?”
The personal answer is, who knows? I don’t think anyone in the family had a habit of saying it, so it must be the product of my lifetime immersion in popular entertainments.
But in an “origin of the phrase” sense, it’s easy to find what purport to be answers: here (sort of official looking), here, and here among many others, though none really get beyond the obvious meaning of the phrase to tell you much about how it came into use.
(On the inevitable donuts vs. doughnuts debate: Google shows 21,800 hits for “dollars to donuts” and 11,300 for “dollars to doughnuts.”)