The expression “What the deuce‽” can be used to express surprise, shock or bafflement. It’s an example of a minced oath in which deuce is used in place of devil [source].
If you run like the deuce, you are running very quickly and wildly, or like the devil, or maybe like you’re being pursued by the devil.
Apparently deuce was first used in the 17th century exclamations and was associated with bad luck or mischief, because when playing dice, deuce (two) is the lowest and most unlucky throw. The connection with the devil developed later [source].
Deuce also appears in the phrase there will be the deuce to pay (there will be a huge amount of trouble).
In card games deuce refers to a card with two pips. In baseball a deuce is a curveball. In tennis it refers to a tied game where either player can win by scoring two consecutive points, and in Canadian slang it refers to a two-year prison sentence.
It comes from the Middle English dewes (two), via Anglo-Norman from the Old French deus (two), from the Latin duo, from the Proto-Italic *duō (two), from the Proto-Indo-European *dwóh₁ (two) [source].
Deuce might also be linked to or come from the Late Latin dusius (phantom, specter), which comes from the Gaulish *dusios (incubus, monster), probably from Proto-Indo-European *dʰeus- (spirit) [source].
Alternatively it might be linked to the Old French deus (God), from the Latin deus (god, deity), from the Old Latin deivos, from the Proto-Italic *deiwos, from Proto-Indo-European *deywós, from *dyew- (sky, heaven) [source].
Other Anglo-Norman numbers that are/were used in cards, dice and other games include ace (one), trey (three), cater (four), cinque (five), sice (six) [source].