This phrase means "a timely effort will prevent more work later" The stitch in time is simply the sewing up of a small hole in a piece of material and so saving the need for more stitching at a later date, when the hole has become larger, Clearly, the first users of this expression were referring to saving nine stitches.