The short answer is, we don't know. For such a popular phrase, used by everyone from baby-wear advertisers and Wall Street analysts to Robert de Niro (A Bronx Tale) and "Star Trek," its origins remain frustratingly obscure.
But you're correct that the phrase is mainly associated with desperate gamblers, principally crapshooters. It even gave its name to a low-budget 1974 "blaxploitation" flick about a numbers kingpin's attempts to stay in business as the Mafia and police close in around him (later retitled Jive Turkey).
It's a favorite of lyricists as well as Hollywood script writers. For example:
"Shine, shine, shine 'em up fine, Shine 'em up fine for a dime! My baby needs a new pair of shoes! Come on, you seven! Roll you 'leven! And he won't get 'em if I lose! Hop up you 'leven! Roll you 'leven! Roll, roll, roll dem bones, Roll dem in de square, Roll dem on de sidewalk, Streets or anywhere! We roll dem in de morning, We roll dem in de night. Oh, we roll dem bones de whole day long When de cops are out of sight!"
History doesn't relate who wrote this song, but the track was recorded by Bill "Jazz" Gillum, sometime in the late 1930s or '40s, and appears on "The Essential Jazz Gillum" CD, which you can find on-line for around $12.
Although we can't guarantee — and in fact doubt — that this was the first ever use of the phrase, this last song at least seems to bring us pretty close to that point, and marries up the whole shoe thing with the game of street craps. The phrase obviously has a long history, stretching back at least to the 1930s, when it was already being used as a plea to the gambling deities, specifically in conjunction with the game of craps.
As ever, if anyone has anything additional or more definitive to add, please let us know.