Pope St. Pius V established this feast in 1573. The purpose was to thank God for the victory of Christians over the Turks at Lepanto - click here for survey of the battle - a victory attributed to the praying of the Rosary. Clement XI extended the feast to the universal Church in 1716.
The development of the Rosary has a long history. First, a practice developed of praying 150 Our Fathers in imitation of the 150 Psalms. Then there was a parallel practice of praying 150 Hail Marys. Soon a mystery of Jesus' life was attached to each Hail Mary. Though Mary's giving the Rosary to St. Dominic is recognized as unhistorical, the development of this prayer form owes much to the followers of St. Dominic. One of them, Alan de la Roche, was known as "the apostle of the rosary." He founded the first Confraternity of the Rosary in the 15th century. In the 16th century the rosary was developed to its present form—with the 15 mysteries (joyful, sorrowful and glorious). In 2002, Pope John Paul II added the Mysteries of Light to this devotion.
The greatest retelling of the victory at Lepanto is by G. K. Chesterton in his epic poem of the same name.