The text was probably written some time in the 1400s. The song was part of a "mystery play" (a play about the mysterious god-and-human nature of Jesus Christ) presented by the tailors and fabric-cutters guild in the city of Coventry, Warwickshire, England. The text is written in the first-person, and depicts three women of Bethlehem discussing the upcoming "Massacre of the Innocents" by King Herod (which occurred two years after Jesus' birth).
The song probably had a different melody over the centuries, but by 1591 had this melody. The origin of the melody is unknown, although it is probably French. It is a Picardy third, which means that the final chord is shifted into a minor key or a "modal" form. The song is designed for three parts, alto, tenor and baritone. That's because, as was usual with mystery plays, the female roles were played by men.
The Coventry Carol was fairly obscure until World War II. The Luftwaffe began bombing the city of Coventry in August 1940. After a brief lull, the Luftwaffe attacked Coventry again beginning at 7:20 PM on November 14. Forty minutes later, the Luftwaffe hit Coventry Cathedral, destroying it. The all-clear was sounded at 6:15 AM the next morning.
The BBC's Empire Broadcast on Christmas Day 1940 concluded with the singing of the carol in the bombed-out ruins of the cathedral. The effect was incredibly powerful, making Coventry Carol one of the most popular carols of the mid-to-late 20th century.