The ancients---Babylonians, or Egyptians, I am too lazy to look up who, and in fact it may well not be known---divided the day into 12 and the following night into 12. Each 'hour' thus produced was assigned a planet, in order of the speed they move through the fixed stars:
- Saturn (which goes round slowest, taking 29 years)
- Sun (which goes round once a year, through the zodiac)
- Moon (which goes round once a month)
The next hour is assigned to Saturn again, and we repeat the set.
In this graphic, the circle represents the day from sunrise today until sunset today, followed by the night from sunset today until sunrise tomorrow in darker colours. Hover or click on the hours to see the ruling planets and their timings.
If you look on a Sunday, you'll see the Sun (yellow) gets the hour beginning with sunrise, followed by Venus, Mercury, etc., all the way round to the last hour of the day (Saturn), and further on to the hour just before sunrise tomorrow (Mercury)
The planet after Mercury is the Moon, so the Moon gets the hour beginning with sunrise on the next day. The days get their names from the planet that rules the hour of sunrise.
The last hour of Monday night is Jupiter's, so Tuesday starts off under Mars. In English this has gone through a Saxon/Norse filter so we have Tiw there, but French 'mardi' is more obvious.
Going round the week Wednesday's sunrise is with Mercury (French 'mercredi'), Thursday with Jupiter (French 'jeudi'), Friday with Venus (French 'vendredi'), and Saturday with Saturn.
Every day there are 24 hours, which is 3 planetary sets and 3 left over, so we skip 3 places in the list. Because 24 and 7 don't have any common factors, we get through all the planets before repeating ourselves, and the weekly pattern is established.
Although most languages have replaced some or all of the days in this scheme, some---like Welsh, or Tibetan---retain the complete set.
In fact almost every culture in the world uses a seven-day week, and appears to have done so from time immemorial. And every culture that names the seven days after planets names them in the same order, skipping as we've seen by 3 each day. So the sequence of planetary hours is the most widespread, and probably longest-lived, human tradition in existence.
NB: I have not fact checked the last paragraph.