From the Wikipedia:
"Originally observed as the Feast of Our Lady of Victory, its date was chosen to commemorate the European victory at the third naval Battle of Lepanto in 1571. This battle marked the high point of Turkish (Muslim) advance on European soil with the Balkans and the regions west and north of the Black Sea returning to Western (Christian) hands in the succeeding centuries. This victory, after two earlier defeats at the same location, was attributed to Our Lady of the Rosary as special processions were made on that same day in Rome for the sake of this crucial victory.
Pope Pius V ordered that a commemoration of the rosary should be made upon that day, and at the request of the Dominican Order Gregory XIII in 1573 allowed this feast to be kept in all churches which possessed an altar dedicated to the rosary. In 1671, the observance of this festival was extended by Clement X to the whole of Spain, and somewhat later Clement XI after the important victory over the Turks gained by Prince Eugene on 6 August, 1716, at Peterwardein in Hungary, commanded the feast of the rosary to be celebrated by the universal Church. A set of "proper" readings were approved by Benedict XIII."