The composers of the earliest written music, like chant and medieval polyphony, identified their works by the incipit of a text. Thus Pérotin’s 20-minute-long Sederunt principes, even in a 12th-century manuscript, didn’t have a title page or a heading at the top of the first page of score: “Sederunt principes, organum in 4 parts,” but would be known by the text of its cantus firmus, even though the successive syllables of the tenor might be several pages apart.
Two centuries or so later, Guillaume de Machaut (1300-1383) left chansons to posterity—his music with his own verses. We know these songs by the first line of text. He also left a complete Ordinary of the Mass, with an actual title: Messe de Nostre Dame. Within another century, dozens of Mass compositions would become well known in church use, and these would be identified by title and usually by composer as well: Josquin des Prez left a Missa Pange lingua (based on a chant, a Good Friday hymn), a Missa Hercules Dux Ferrariae (on a “hidden subject”), and of course a Missa l’Homme armé (on a popular song), as did a dozen or more other composers.
During the High Renaissance (16th century) titles begin to emerge that indicated specific formal types independent of texts; these tell the prospective listener at least something of what to expect. The title Diferencias sobre Guardame las vacas refers to the popular song that is the theme, but otherwise indicates diferencias as a formal type, one variation followed by another. The chaconne, and later the passacaglia, arose as a continuous-variation form. In this period, dance forms generate musical titles, and these multiply in the Baroque era: sarabande, passepied, galliard, allemande, gigue, bourrée, all imply stylized group dances, and these usually have identifiable musical properties, such as specific meters (sarabande in slow triple meter, gigue in fast 6/8, etc.). From the middle 16th century, some titles suggest more style than form: prelude (praeludium), fantasia, toccata, etc., imply non-sectional extended pieces with a mixture of styles, and this tendency continued through Bach and Mozart into the 19th century and even beyond; a fantasia might be paired with a contrasting fugue, identifiable as to form but more uniform in style. In opera, another product of the 16th century, a title could mean a principal character or characters, or a main subject, but essentially functioned just like the title of an Elizabethan play, a name on a rural mailbox, or a coat of arms over the door of a shop. That’s also true of big titles like The Well-tempered Clavier, like the gold lettering on the binding of a multi-volume set, even though by itself it tells you almost nothing of what’s inside.