‘Toe the line’ means to follow orders, to do as you’re told, conform to a set standard, or to not rock the boat. An alternative phrase that means exactly the same thing is ‘toe the mark’.
It’s often misspelt as ‘tow the line’, since the nautical term to tow something (drag something behind a boat via a line) sounds very similar, and also involves lines (usually, a rope).
Common theories on the origins of the expression include sporting events, where athletes line up with their toes literally on a line; the armed forces; and English public schools, where students would line up for roll-call. Wikipedia offers some entertaining alternatives, including lines separating armed politicians by a minimum distance to restore decorum during heated debates.
Examples of ‘toe the line’:
If you want to keep your job, you’d better toe the line.
She toed the party line when it came to immigration.
This phrase is very common in UK and US English, as is, unfortunately, the misspelling I noted earlier. Sources are notably unclear on when exactly it came into use, but the practice of scratching a line in the dirt to serve as a starting point for races, duels, or even ‘cross this and I’ll turn you into jam’ has been around for at least a couple of centuries – most likely, much longer.
It’s a nice colour phrase that usually adds a slightly ominous shading to the context, and could be used in most contemporary fiction. In sci-fi or fantasy genres, it could be adapted to match a culture from your world, and shouldn’t be used verbatim. In historical fiction, you run the risk of anachronism without doing a lot more careful checking on exactly when the phrase started to be used.
What is etymology, and why are you excavating it?
Etymology is like the archeology of a language (definition: the study of the origin of words and the way in which their meanings have changed throughout history).