I understand how we came with the concept of days and years. Those are fairly easy with the sun coming up and down and the seasons.
However, I have always been curious how or why people decided to divide a day into 24 even "segments" why not 10 or 50 or any other number? And how and when did people decide to divide a 24th of a day into 60 smaller segments and those segments into 60 smaller segments.
The reason has to do with numbers; specifically, the numerical system in use by those civilizations which were credited with dividing up the days into smaller slices.
We are used to our Base 10 numerical system (i.e. we use combinations of the symbols 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 to represent all possible numbers in our system), but the Babylonians used Base 60 and the Egyptians used Base 12.
The Egyptians are largely credited with the creation of the sundial, which used their numerical system to divide the daylight hours into twelve units (if we were to invent timekeeping today, we'd probably divide daylight into ten equal sections because we use Base 10).
Minutes and seconds are a little more difficult to explain because they weren't widely used until the technology existed to resolve them correctly on a clock, but they have their roots in the Babylonian numerical system as well. The short version is that minutes were originally used to represent the division of our globe into sixty sections by the Greeks, who used long-held numerical conventions established by the Babylonians. These 60 divisions were each then divided another 60 ways to produce 60 "second minutes."
This system was originally created for navigation and cartography but the conventions eventually found their way into timekeeping. It's no coincidence that clock faces are round.
On mobile but can provide sources later.
Edit: For a more detailed exploration of this question, I recommend Time's Pendulum: From Sundials to Atomic Clocks, the Fascinating History of Timekeeping and How Our Discoveries Changed the World by Jo Ellen Barnett (1999).
Also, thanks to user /u/hsxp for providing some good mathematical context on the Base 12 and Base 60 numerical systems in his comment below.