Count Franz Walsegg-Stuppach was the person responsible for the commission of the Requeim. His very young wife had died in Feburary 1791; and a large statue of her was also commissioned as a memorial. The Requeim was to be composed for his own personal use; and would be performed at yearly memorial Masses in his wife's honor. Count Walsegg was a talented musician who had the habit of hiring composers to write pieces of music, then rewrite the music in his hand and play it to friends as his own (see the parallel with Amadeus' storyline).
Mozart was hired to write the music around July 1791. But he was very busy during this period with the composition of the Magic Flute; and then when that was done,he got another opera commission for "La Clemenza di Tito" for the coronation rites of Emperor Leopold II the following October. Mozart only got this commission because of a strange series of events that prevented Saleri from writing the score (that's another story though). Finally by Nov of that year Mozart was able to start work on the score. From paper studies by Alan Tyson we know he worked pretty fast on what survives. Mozart wrote most of the Requiem (no doubt some sketches that haven't survived) in about 25 days.
During a performance of a small Masonic cantata, Mozart apparently caught a streph infection and this set off the chain of events that caused his death. Dr. Peter Davies has examined all surviving records for Mozart's life (it's pretty extensive); and diagnosed Mozart as having Henoch-Schönlein syndrome.
HSS is a disease that can be fatal without proper treatment-which of course didn't exist in Mozart's time. If you have a mental vision of Mozart laying in a bed daintly writing in his score--throw that away. His death was very painful and violent (projectile vomiting, bleeding and bruising from his vascular damage, acute pain in his gut). He eventually suffered a stroke.
It seems likely the Kyrie from the Requiem was performed at a makeshift memorial service to Mozart within a few days of his death. Amadeus was historically correct to the "T" showing the corpse being thrown into a paupers' mass unmarked grave.
Mozart's wife Constanza did not want to renounce the commission and lose the large fees promised for the finished product; so she found someone to finish the Requiem. After some stops and starts with various candidates to fill out Mozart's unfinished manuscript, the score was handed over to Count Walsegg by the following Feburary. But Constanza also sold a copy to the King of Prussia and sold publishing rights. Count Walsegg was both horrified and angry at finding out about Frau Mozart's violation of his commission. Legal action against Constanza was considered by Walsegg until he was persuaded she needed the money to raise her two boys.
Constanza played up the poor widow angle the rest of her life. But we know historically she was doing so well, that within a few years of Mozart's death, she was able to lend a friend a considerable amount of money. Constanza also firmly held the public line that Mozart was responsible for every single note in the Requiem. She always denied any role Sussmayer had in finishing the score.