It's toE the line, not toW the line. As such, since the early 1800s - Captain Marryat uses it in his naval stories, for example - it has meant to come up to scratch. That last phrase itself comes from the same source. The 'line' referred to is an imaginary line or a real one scratched into the sand or marked on a ship's deck, for example, which is to be used as a guideline for someone to place his feet. In the old days, boxers had to toe the line before the bout started. In a similar way, athletes have to toe a line before the starting-gun and so on.