The origin is from ancient prisoner restraint methods -- approximately around the late middle ages, prisoners wore a heavy metal ball attached by a chain on their legs, to prevent them from making a run for their freedom (or at least, that is the way medieval prisoners are often depicted in modern popular culture).

The allusion is that one's wife will not let one go anywhere (mostly meant as "go out", rather than "run away from her"), much like the ball and chain.