Why do we divide time into weeks? Is there any celestial reason why humans do this?
- one year: earth revolution around the sun
- one month: moon revolution around the earth
- one week: 7 days = ???
- one day: earth rotation about its axis
The synodic period of the moon is $29.53$ days, a little shorter than a calendar month, which is on average about $30.4$ days. This is slightly longer than its orbital period, but corresponds to the periodic visual appearance of the moon as viewed from Earth. I mention this to make it clear that we should be forgiving of a little imprecision.
Conventionally, the moon's appearance is divided into four phases: first quarter, full, last quarter, new. That means that on average, each phase lasts about $7.4$ days. Since calendars count days in integer amounts, a $7$-day period seems to be a natural choice.
The social importance of the seven-day period in Western cultural probably has much more to do with its religious significance in Abrahamic religions than astronomy per se (although certainly not unique to it). But its ultimate origin probably does lie in the natural division of the moon's appearance into four phases, which correspond to an apparent geocentric celestial latitude difference between the Moon and Sun of $0^\circ$, $90^\circ$, $180^\circ$, and $270^\circ$.
That, the explicit answer to your question is
The modern 7-day week was adopted in the late Roman Empire, replacing an 8-day "nundinal week" that had previously been in use mainly for market intervals. As far as I know, there was no particular reason for the 8-day length other than that it was a convenient size to separate market days.
In the early Empire, Christians and Jews both used a 7-day week for religious purposes and as they grew to be a major part of the Empire's population, it became convenient to link the market week with the religious week. This worked because 7 worked about as well as 8 for markets, and so by the late Empire, it was a done deal.
See https://en.wikipedia.org/wiki/Nundinae for a good discussion.
Where did the Jewish 7-day cycle come from? It's not certain. A practical market cycle can be anywhere in the 5-10 day range -- it doesn't matter a lot -- so if early Jews preferred a 7-day religious week (from Genesis, Chapter 1, probably) then the market cycle would have synched up just like in the Roman Empire. It's also possible they inherited it from some previous mid-Eastern culture. I doubt anyone knows for sure any more, so it must remain to some degree speculation.
The 7 days of the week certainly fit somewhat as a quarter of a month. But there was another argument for the ancients to use the number seven, because they knew about seven "planets", seven objects which wander across the sky relative to the thousands of fixed stars. The Sun, the Moon, Mercury, Venus, Mars, Jupiter, Saturn. Earth wasn't a planet according to the IAU definition at the time. Earth was instead the center of the universe.
The weekly calendar of the ancients was pretty busy:
Sunday - Sun you're free, sober up and get a suntan
Monday - Moon the day after being free
Tuesday - Jupiter Zeus day, be clever and figure something out
Wednesday - Mercury go somewhere and talk about it
Thursday - Mars fight
Friday - Venus make love
Saturday - Saturn please take a bath!