The choice was made on simple astronomic facts: The earth circles the sun in roughly 360 days, a moon phase takes roughly 30 days. Building a calendar on these, you easily arrive at a base 12 system, since 360/30=12. The Babylonians did that already in ancient times.
Then, if you simply apply the same unit for the earth’s rotation, you have a scale for a sunclock that nicely fits your calendar. Ok, it’s 24 hours but you only get about 12 hours of sunlight.
Quite pragmatic, actually.
Fun fact: The french revolution tried to use base10 for everything. There were also a decimal calendar and a decimal clock! But they didn’t catch on.
The reason for this is called path dependency. Many processes and conventions are based on the base12 system. Changing them would introduce costs that would exceed the convenience of a base10 system (change calculation models, convince stubborn people, …). Sometimes the better solution is too hard to establish. Also, you never know if it really is better before you roll it out.
A similar discussion is that about the Dvorak and other keyboard layouts.
Latest Answers