ß is a consonant letter nowadays unique to the German language, where it is used to denote the voiceless alveolar sibilant [s] after long vowels and diphthongs. Yet, until the 19th century, ß was also in use in many other European languages like English, French, Danish, or Italian.
The question for its origin may sound silly to the reader at first since the letter’s appearance and its two names “Scharfes s” (Sharp s) and Eszett (lexicalized for sz) already suggest two possible origins:
1) A ligature of long s and short s : fs -> ß
2) A ligature of long s and tailed z: fʒ -> ß
Which option is the correct one? It turns out that there is no simple answer to this question and hence to the title question as well. The evolution of ß is not fully understood and requires to consider linguistic and typographic aspects. In fact, it might well be that both options are correct to some extent.
fʒ seems to have come into use in German blackletter writing starting around 1300 when it denoted the sound [s] in places where it resulted from original Germanic [t]. fs seems to be of romanic origin and appears first around 1500 in Italian antiqua fonts. Yet, little is known about the interplay of the two ligatures fs and fʒ and when they gave birth to the modern letter ß.
– Jacob and Wilhelm Grimm, Deutsches Worterbuch, volume 14, Leipzig, S. Hirzel, 1893, column 1573.
– Jan Tschichold, Herkunft und Form des ß in der Fraktur und der Antiqua, in: Schriften 1925–1947, volume 1, Brinkmann & Bose, Berlin 1991, pages 242–244.
-Herbert E. Brekle, Zur handschriftlichen und typographischen Geschichte der Buchstabenligatur ß aus gotisch-deutschen und humanistisch-italienischen Kontexten, in: Gutenberg-Jahrbuch, Mainz 2001, pages 67-76 (online: http://www-nw.uni-regensburg.de/~brh22505/Ligatur/LIGATUR.HTM).