In 1747, Maximilian married his first cousin, Maria Anna Sophia of Saxony, but the marriage remained childless. During the Seven Years' War Bavarian forces then fought on the Habsburg side. Maximilian Joseph's sister Maria Josepha of Bavaria was married in 1765 to Maria Theresa's son Archduke Joseph. But long-term weakening of Prussia was not in the Bavarian interest, as that country offered the only counterweight to the Habsburg monarchy. Maximilian Joseph tried, as far as possible, to keep Bavaria out of the wars. Apart from militia troops, he sent only a small force of 4,000 men to join the Austrian army. In 1758/1759 (only a year and half into the war), he withdrew Bavarian auxiliary troops from Austrian service. Together with the Wittelsbach Elector Charles Theodore of the Palatinate he enforced the neutrality of the Empire during the conflict.
Maximilian Joseph was a progressive and enlightened ruler who did much to improve the development of his country. He encouraged agriculture, industry, and exploitation of the mineral wealth of the country, and abolished the Jesuit censorship of the press. In 1747 the Nymphenburg Porcelain Factory was established, while the Codex Maximilianeus bavaricus civilis was written in 1756. In 1759, he founded Munich's first academic institution, the Bavarian Academy of Sciences. During the severe famine in 1770 Maximilian sold some of the crown jewels to pay for grain imports to relieve hunger. In that year, he also issued an edict against the extravagant pomposity of the Church which contributed to the end of the era of Bavarian rococo. He also forbade the Oberammergau Passion Play. In 1771 the elector regulated general school attendance. In December 1777 Maximilian Joseph rode in his carriage through Munich; on the ride, as he passed one of the tower clocks, the mechanism broke, and the clock struck 77 times. Commenting to the passengers, Max Joseph decided this was an omen, and that his years had run out. Within days, he was stricken with a strange disease. None of his 15 doctors could diagnose it, but by Christmas, it had become clear that it was a particularly virulent strain of smallpox, called "purple small pox" at the time.[1]
By the last day of the month he was dead without leaving an heir. Maximilian III Joseph is buried in the crypt of the Theatinerkirche in Munich.
Maximilian's widow Maria Anna Sophia of Saxony and Maximilian's sister Duchess Maria Antonia of Bavaria as well as Maria Anna of Palatinate-Sulzbach, the widow of the former Bavarian crown prince Duke Clement Francis of Bavaria negotiated with Max's reluctant heir and intervened together with Frederick II. of Prussia and the new elector's presumptive successor, Charles II August, Duke of Zweibrücken, to secure Bavaria's independence from Austria. The Prussian king had to threaten both the emperor and Bavaria itself with war. Austria had already invaded portions of the duchy immediately after the Elector's death and the new elector had less than any interest in his new realm. Instead, Charles Theodore, much to public annoyance, repeatedly tried to change it for Further Austria or the Austrian Netherlands, even better, for proximity to his Palatinian homelands.[2]
Wolfgang Amadeus Mozart was received by Maximilian III Joseph, who was like his sister Maria Antonia Walpurgis of Bavaria skilled in music and composed, but due to a need for strict frugality no post could be offered. In 1775 La finta giardiniera, an Italian opera by Wolfgang Amadeus Mozart, received its first performance at the Salvatortheater in Munich.