Italian composer Gregorio Allegri (1582-1652) composed a setting of Psalm 51 ("Miserere mei, Deus," or "Have mercy on me, O God") during the reign of Pope Urban VII. The piece was written for use in the Sistine Chapel during Holy Week - specifically, during matins on Wednesday and Friday. The piece is in many ways "common" to 17th century choral music. It is, however, an uncommonly beautiful piece, and soon after its composition the Roman Popes reserved exclusive rights to the score and performance of this work. It became forbidden for the music to be copied or published, or performed anywhere outside of the Vatican at those two services each year. Disobedience on this matter was punishable by excommunication. The only authorized copies outside of the Vatican were un-ornamented - and it was and is the ornamentation practice that makes the piece so exquisite.
In 1770 young Wolfgang Amadeus Mozart, at the age of just fourteen, visited Rome and heard the piece during the first of the two Holy Week performances, on Wednesday. The story goes that after the service he wrote the piece down from memory - and then returned to the chapel on Friday to check his work and make any needed corrections.
Leopold Mozart, Wolfgang's father, wrote in a letter to his wife,
"You have often heard of the famous Miserere in Rome, which is so greatly prized that the performers are forbidden on pain of excommunication to take away a single part of it, copy it or give it to anyone. But we have it already. Wolfgang has written it down and we would have sent it to Salzburg in this letter, if it were not necessary for us to be there to perform it. But the manner of performance contributes more to its effect than the composition itself. Moreover, as it is one of the secrets of Rome, we do not wish to let it fall into other hands, ut non incurramus mediate vel immediate in censuram Ecclesiae."(From The Letters of Mozart and his Family by Emily Anderson)
Wolfgang's sister Marianne (called "Nannerl") recorded her memory of the event, as well:
"...they traveled on the 15th March 1770 to Parma, Bologna, Florence, [on] to Rome, where they arrived during Holy Week. On Wednesday afternoon they accordingly went at once to the Sistine Chapel, to hear the famous Miserere. And as according to tradition it was forbidden under ban of excommunication to make a copy of it from the papal music, the son undertook to hear it and then copy it out. And so it came about that when he came home, he wrote it out, the next day he went back again, holding his copy in his hat, to see whether he had got it right or not. But a different Miserere was sung. However, on Good Friday the first was repeated again. After he had returned home he made a correction here and there, then it was ready."(From Mozart: A Documentary Biography by Otto Erich Deutsch)
Word of the work having been copied - and subsequently published - reached the Pope, and Mozart was summoned to Rome, where he was not excommunicated but rather was praised for his genius!
The history of the piece - its falsobordone composition style, harmonic structure, two-choir setting, ornamentations, and performance practice - is far more rich and complex than I can detail here, but if you're interested in learning more, I recommend this site.
Mostly I recommend you listen to it.
Deliver me from bloodguiltiness, O God, thou God of my salvation:
and my tongue shall sing aloud of thy righteousness.
O Lord, open thou my lips; and my mouth shall shew forth thy praise.
For thou desirest not sacrifice; else would I give it:
thou delightest not in burnt offering.
The sacrifices of God are a broken spirit:
a broken and a contrite heart, O God, thou wilt not despise.