Since the dawn of time, man used the sun to gauge the state of the day. In the short span of civilized man, we started putting specifics to the day with sun dials and then the watch. But who was the guy that pulled out of the sky (pun intended) that there should be 24 hours in a day? Is it a function of the length of an hour, if so who decided that?
It may have been the Babylonians. They’re the ones who decided that there are 360 degrees in a circle, after all.
Probably the ancient Egyptians are the origin of the number 24. However…
The above page doesn’t say so explicitly, but for the Egyptians the hours were not of constant size. There were always ten hours in a day and twelve in a night (and two for twilight) — even as the relative proportions of day and night changed over the course of a year.
Later on of course, after mechanical clocks were invented, the day was divided into 24 equally sized pieces.