The day is 24 hours long because that is approximately how long it takes for the Earth to rotate fully.
If you mean why is an hour the amount of time they decided to use, that I have no answer for because time is a totally arbitrary construct. I imagine that time was in use before people discovered that the Earth rotated the way it does, because otherwise we’d have no leap year (which is a byproduct of our system of time not being exact enough)
I think the better question is why 7 day weeks? I was unemployed for a couple months and realized that the whole Monday thru Friday, with 2 days off, makes no sense. Days and months are completely made up to keep us from falling out of the bill cycle, keeping us enslaved to some degree. The only real thing is seasons.
My father explained it once as being a divisible of the circular (360°) rotation of the Earth. It was part of a much longer explanation of the natural balance of 6-cylinder engines, but I was a teenager, and was distracted by thinking about girls at the time.
Also, he was a mathematical genius, and I, to say the least, ain’t.