Centuries ago, people said “of the clock” when they told someone the time, as in “six of the clock.”
Then in the 17th and 18th centuries, this phrase was shortened to “of clock” or “a clock.”
Finally, in the early 18th century, these terms were shortened still further to “o’clock.”