In 1854 Pius IX gave the infallible statement: The most Blessed Virgin Mary, in the first instant of her conception, by a singular grace and privilege granted by almighty God, in view of the merits of Jesus Christ, the savior of the human race, was preserved free from all stain of original sin.
It took a long time for this doctrine to develop. While many Fathers and Doctors of the Church considered Mary the greatest and holiest of the saints, they often had difficulty in seeing Mary as sinlesseither at her conception or throughout her life. This is one of the Church teachings that arose more from the piety of the faithful than from the insights of brilliant theologians. Even such champions of Mary as Bernard and Thomas Aquinas could not see theological justification for this teaching.
Two Franciscans, William of Ware and Blessed John Duns Scotus, helped develop the theology. They point out that Marys Immaculate Conception enhances Jesus redemptive work. Other members of the human race are cleansed from original sin after birth. In Mary, Jesus work was so powerful as to prevent original sin at the outset.