The History of Analog Clocks provides an explanation of the origin of the 24-hour day. The system dates back 4,000 years, to ancient Egypt and Babylon.
Egyptian astronomers divided the night hours into 12 distinct sets of star patterns, which emerged over the horizon at roughly hour-long intervals. They divided the day into 12 hours to match, and because they lived near the equator, the days and nights were of roughly equal length throughout the year.
Throughout the rest of the world, the 12 “hours” of the day and night were flexible depending upon the season. It wasn’t until the 13th century A.D. that an Arab scientist named Abul-Hassan suggested the idea of clearly defined hours.
It’s also worth noting that the number 12 is special in many cultures. For example, Egyptians counted in base 12. Dividing the day into two sets of 12 was a simple and elegant way of condensing the annual calendar into a day.