The expression “o’ clock” comes from a time in which people were using various ways of telling the time. One of them was the clock.
Back in the 12th century when clocks weren’t so prevalent, people told time by a variety of means. Of course, the sun was always used as a reference point but, solar time was different that clock time and it varied according to the seasons. Clocks, on the other hand, divide the time evenly.
The expression “o’ clock” was used to distinguish the fact that someone was referring to clock’s time (and not solar time). They would say “It’s nine of the clock” which later became “nine o’ clock”.