The story
From horse racing, hiding (“beating”); to (“as used to express gambling odds”), e.g., 6 to 1. Literally, the phrase can be described as to bet on a contest whose outcome is at worst a beating, or at best nothing. A heavily favoured team in a sporting contest earns no credit for victory, but is shamed by defeat; this team is said to be on a hiding to nothing.
Etymology from Wiktionary, CC BY-SA 4.0.