OK, there are a lot of factors involved here that don't lend to a simple answer.
All that being said, the answer to "why is there so much sacred music in the Western Classical Choral repertoire" still has a lot of points to it.
First off, the Catholic church had money. Lots and lots of money. There were some of the only people wealthy enough to commission any kind of art. If you look at the vast amounts of art in Western Europe from the Middle Ages on, you'll see an absolute plethora of religious art. Same with music. The Catholic church wanted music, and so they hired musicians and composers to write and perform it. There was still plenty of secular music happened around this time, but not as organized, and very little of it has been written down and preserved, which leads to the next point - the church is an excellent archivist.
If you write a piece of music for the church, it's far more likely to be written down, and far more likely to be well-preserved. If you're a troubador in the middle ages, even one in a cushy appointment with a weathy nobleman, where you're not moving around a lot, you're still pretty unlikely to be writing any of your music down, and the nobleman isn't likely going to want a written copy of it, let alone preserve written copies for posterity. Not to mention that music notation was by no means standardized in the middle ages, and it wasn't until the late Renaissance/Early Baroque era that we got a reliable system of music notation that was mostly standardized, assuming the secular travelling musicians were even literate in the first place enough to write their music down (it happened, but not to the extend of the church).
Next, in the middle ages singing was the ONLY music allowed in the church. Instruments were considered too earthy and secular, and were by and large discouraged, if not banned outright until the advent of the pipe organ in the church, which didn't happen until the 1600s (depending on which part of Europe you were in). Singing was seen as another form of prayer, and monks and nuns were not only singing it, they were also creating it and writing it down, in addition to non-monastic composers hired by the church. Since monastic orders were far more literate than the average middle aged person, there are huge volumes of music written by monks and nuns for the church which, obviously, would be all sacred in nature. Most were written anonymously, or the names were lost over time, but we know the names of some of them. Hildegard von Bingen was a German nun who wrote a great deal of music, among her other talents, and Moniot d'Arras was a monk who was also a musician and poet. So these religious orders would have the capacity to write their music down, and be in a far better position to preserve it for the ages. In addition, this music was copied and shared, so there would be a far greater volume of it going around.
Keep in mind, while all this was happening, there was still a lot of secular music happening, even at the height of the middle ages but, again, less of it written down at all, let alone written, copied, and preserved.
Now, let's skip ahead to the Baroque era. You now have more literate people, more composers, and a whole new style of music being created which will eventually become the benchmark for all the Western music to come. However, you still have the church with a lot of money, but you also see the rise of Protestantism, and the newly formed churches are also commissioning composers to write music. Look at J.S. Bach, for example. He was employed by St Thomas' Church in Leipzig, and was paid to write music for the Lutheran Church. But at the same time, he was writing a ton of secular stuff as well. However, the church still likes its choral singing and organ, so you'd get a lot of that, although instruments were being introduced by this point as well, as evidenced by Bach's pletora of cantatas which are, essentially, mini symphonies for small orchestra and choir to commemorate the particular day in the church calendar. Bach wrote enough of these for 7-9 YEARS without repeating a single piece, and that's in addition to the thousands of other pieces he wrote. Other composers of the era included Vivaldi, who was a priest who wrote a great deal of music from his orphanage in Venice, but also wrote securlar works, including an insanely large number of operas, which were pretty much all secular (or based in Greek/Roman mythology, which may count as sacred or secular depending on your point of view). Same with Handel - he wrote Messiah, and Israel in Egypt, as well as sacred cantatas, hymns, and more, but wrote probably an equal amount of secular works, including operas, songs, concertos, sonatas, and much more.
This trend generally progressed over time with the church slowly losing money, power, and influence over the musical world as composers took secular patrons, and wrote more secular works. Still, there were many noble patrons who wanted religious music written for them, and they would comply.
Another thing I should mention (I told you this didn't lend itself to a short answer), is the local church would often have a choir and organ master in its employ, so they would commission works with the exact instrumentation they had in mind. Not all churches could afford an orchestra, even if they wanted one, but most would have a choir and organ on hand, so they would commission works for choir and organ, or choir alone. Whereas a nobleman, if he had any musicians employed with him at all, they would be more likely to be instrumentalists, so you'd see a bunch of works written for a particular group of instruments, or a particular voice commissioned for a certain occassion. In the secular world, this would be more broad, but in a church, it was more likely to be choir, or choir an organ. Again, these are generalizations - some churches employed orchestras regularly, tons of operas have vast choruses, and so on, but giving you a broad idea of how things would have played out.
Now, STILL while all this was going on, and even today, you had a wealth of folk music being played throughout Europe in many different styles and traditions, on a wide variety of instruments. The most famous would likely be Scottish bagpipe music. There are thousands (probably much more than that) pieces, nearly all secular, many passed down by rote, or by a variety of folk notation techniques that would all have been taking place at the same time, in conjunction with the classical tradition. Modern scholarship has paid scant attention to this kind of music, but for many people in the last 1-2 thousand years, this would have been the most common form of music people would have heard - the kind that they made themselves in their communities with their friends and family.
I could go on, but I'll leave it here, and let me know if you want to hear any examples of what I've mentioned, or have more specific questions.