One of the most often cited examples of algorithmic music in the Classical Period (1750-1827) is Musikalisches Würfelspiel by Wolfgang Amadeus Mozart (1756-1791). In this composition, Mozart composed discrete musical excerpts that could be combined to form a waltz. The order of musical excerpts was determined by rolling two six-sided dice. The person assembling the waltz would refer to a table created by Mozart that showed which music should be used for the values of 2-12 on the dice.
After Wagner, there was pretty much nothing new that could be done with tonal composition. So music hipsters everywhere were distraught, and looking for a way to push composition and music theory in general forward. The answer came from Arnold Schoenberg and his followers in the early 20th century in the form of serial composition. Serial composition introduced a set of rules for composition that arguably served to birth algorithmic composition as we know it today.