Like other words in our modern language, the history behind the word ‘O’Clock’ dates back centuries to when things were done differently.
Clocks became mainstream in the 14th century. Before that, people had other ways of telling time, like Solar Time, which is the practise of telling the time of day by the position of the sun (think of a sun dial).
Telling time by the sun and by the clock sometimes gave a different time. Whereas the clock could divide time equally, solar time depended on a variety of factors, like the time of year. So when someone was asked the time, people would make sure to say whether they were giving the solar time, or clock time.
A popular response was to say something to the effect of ‘it’s 5 of the clock’, meaning you were reading the time according to the clock, and not another method. Over time, this saying was slurred to say ‘o’clock’, which is the word we use now.
So when we announce the time ‘o’clock’, we’re actually say that we’ve read a clock and not a sun dial.