Why are there 24 hours in a day?
The dividing of the day into useful chunks of time goes back to our earliest recorded history, and probably through pre-history as well. People in many cultures were of course aware of the regular passage of the sun across the sky, and most realized that the sun follows an arc-like line. The sun reaches a 'highest' point at mid-day and this could be used, along with sunrise and sunset, to begin charting out time periods of various length. They also noticed and studied the movements of the stars as they moved during the night, and as they changed over the year. In our earliest days we certainly didn't need anything nearly as accurate as a second or minute for daily activities, but many cultures had sophisticated ways to mark out some of the basic movements of the sun with great accuracy. The history is long and interesting and you can check the link as a starting point.
There is nothing magical or innately 'physical' about the idea of 24 equal time segments for a day, although this turns out to be a very useful number. We arrived at it over a long period of time, and essentially by convention. Often the ancient Egyptians are credited with getting the system going. There were number systems based on 12 at the time. The significance of the number 12 is mostly due to the 12 lunar cycles in a year and can also be found in other ancient civilizations in China, India and Sumer.
This may be why these systems often started by breaking the daylight period into 12 segments. Breaking the night time up in a similar way was an easy step. It would be impossible to highlight all the subtle quirks involved in our measurement of time, but here are some of them.
The modern 24 hour day is really a rather artificial system; a day measured this way in Universal Time does not match up to a solar day, a day that you would measure from 'solar noon' to 'solar noon'.
The length of a second (and by extension, an hour) is an average, or mean calculation originally based on the length of an entire year. This is why Universal Time was once called Greenwich Mean Time. This is also why Universal Time does not perfectly match the sun's movements. A second is now defined very precisely as a certain number of oscillations of a cesium atom. This definition may hold for many centuries and is now essentially independent of the earth's movement.
Our measurements of time seem to be so regular and absolute, yet as you know we need to add a day to our year to keep our calendars in synch with our yearly revolution around the sun.
What you may not know is that from time to time we need to add a leap second to a year (this is rarely made known to the public-- we really don't need to know. But people who are responsible for communications systems, etc. are made aware of it.) The whole topic is very complex and not particularly easy to grasp. It is a great study for those interested.