"Dafne" by Jacopo Peri was the earliest composition considered opera, as understood today.
Significantly, Dafne was an attempt to revive the classical Greek drama, part of the wider revival of antiquity characteristic of the Renaissance.
The members of the Camerata considered that the "chorus" parts of Greek dramas were originally sung, and possibly even the entire text of all roles; opera was thus conceived as a way of "restoring" this situation.
It was Dafne, (now lost) written by Jacopo Peri for an elite circle of literate Florentine humanists who gathered together as the "Camerata." Significantly Dafne was an attempt to revive the classical Greek drama, part of the wider revival of Antiquity we identify with the Renaissance.
In earlier times, music had been part of medieval mystery plays.
A surviving musical work which is known to be older than Dafne is Philotea, to a religious text, by a priest called Silberman.