The joke is a play on the phrase 'time would run out'.  Time 'running out' means that the time left before an event happens or something ends is drawing closer.  Legs are used to run, so if a clock had legs, the joke is that it would 'run out' which sounds like the clock is running outside.
If a clock had legs , time would run out .