The standard textbook answer is easy. The first opera was Daphne, first performed in 1598 during Carnival at the home of Jacopo Corsi (d.1604) in Florence, music by Corsi and Jacopo Peri (1561-1633), libretto by Ottavio Rinuccini (1562-1621). It is recognized as the first because it was the first of a series of similar pieces which established the form of early 17th century Italian opera, and all subsequent developments were based on that tradition. The score does not survive.
There were many precursors of opera, and you can define it to include or exclude any of them. Corsi, Peri, and Rinuccini were members of a group who believed that the dramas of Classical Greek Antiquity were sung rather than spoken. Medieval liturgical dramas started in about the 10th century. Hildegard von Bingen's 12th century Ordo virtutum can be staged, although we don't know whether it was. The same is true of the anonymous Play of Daniel, Play of Herod, and other liturgical plays from the early 13th century. Adam de la Halle's later 13th century Play of Robin & Marion has been called "suitable for staging," but whether it was intended for staging or ever actually staged we don't know. The early 14th century Roman de Fauvel is also considered by some to be suitable for staging, and a performance of the entire thing would be approximately as long as Wagner's entire Ring cycle! More immediate precursors were the 16th century Italian Intermedio, a madrigal entertainment given between the acts of a dramatic play, and the madrigal-comedy.
But if pride of place goes to a work that is first in a series that establishes an enduring tradition, then Daphne of 1598 is that work and leads in a straight line (well, actually pretty crooked) to Aida, La Boheme and Nixon in China.