While modern music theory doesn't currently have any obvious relation to astronomy, it certainly did historically.
The Pythagoreans were very interested in the relationships between ratios and the natural world, including the orbits of the planets. Their early work on music as being based on harmony and proportions framed how the West approached music for over two thousand years.
The 6th-century Roman Philosopher Boethius declared in the De Musica that anyone schooled in music understood there was three kinds of music: cosmic (aka astronomy), the human (not merely singing but also describing how the body worked) and music "resting in the instruments". He relayed stories and accounts of how certain modes and scales of music would affect mood and could even heal people.
The De Musica was a very important musical text in the West all the way through the medieval era up through the early modern period. The reason that music seemed to have this broad application from astronomy through to medicine was likely because ratios and geometry were the most sophisticated mathematical tools to understand and think about the natural world.
As the medieval period ended, advances in arithmetic techniques (such as Arabic numerals) plus technology such as telescopes enabled astronomers to describe astronomical phenomena more accurately. A huge shift occurred in the way people understood the world as we (humanity) slowly moved from relative geometric measuring to Cartesian-based standardized measurement.
Many instruments we have inherited are from the time when ratio-thinking was dominant with an excellent example of this transition is the violin. The earliest recognizable modern violin shapes were compass and straight-edge constructions, but Stradivarius shapes which are popular nowadays are slightly modified from these more pure geometric constructions (similar to how planet orbits are not actually circles). Even our 12TET scale is a compromise based on–you guessed it–ratios.
Numbers such as seven and twelve show up from this history of ratios to construct scales and dealing with how ratio-based tunings become out of tune as tones are added. Seven tones constructed from simple ratios work well together as a scale: western note-naming is based on this seven notes in a scale system. Most approaches for constructing notes based on simple ratios start to nearly overlap after generating twelve notes, and the latter notes don't play well together without compromising the simple ratios used to construct them.
I can't necessarily explain why there are 12 hours in a day and 12 semitones in a modern western scale (and also 12 inches in a foot). Twelve is a very interesting number as far as factors go. Why the ancient Greeks decided to divide the daylight into 12 hours (from whom we inherited it) doesn't seem overly connected, although there are 12 months in a year and the Horae (goddesses of the hours) were associated with the seasons (Horae means Seasons).
Rather than thinking about how astronomy and music are related, it's better to consider that when geometry was the dominant form of mathematics as it was in the ancient world, applications which fitted geometry really well (astronomy and music) would lend themselves to describing each other and thinkers pondering how they were connected. Similar to how you're pondering that very question now. As for how such relationships could be used, maybe investigate the 16th-century astronomer Johannes Kepler's Music of the Spheres. Better yet, find a copy of De Musica and read it.