The "classical Protestant" position on merit might be summarized as, "All is grace, therefore there is no merit." To someone who accepts this view, Catholic talk about merit on the part of human persons can seem like a denial of God's free (unearned) gift of grace. Thus the vehemence with which the idea of human merit is sometimes attacked.
But does Catholic talk of human merit actually amount to a denial of the unearned character of grace?"
426. What is merit?
In general merit refers to the right to recompense for a good deed. With regard to God, we of ourselves are not able to merit anything, having received everything freely from him. However, God gives us the possibility of acquiring merit through union with the love of Christ, who is the source of our merits before God. The merits for good works, therefore must be attributed in the first place to the grace of God and then to the free will of man.
So, we can see that in the Catholic understanding merit is not something one earns on one's own, but has its source in Christ. How does that work?
2008 The merit of man before God in the Christian life arises from the fact that God has freely chosen to associate man with the work of his grace. The fatherly action of God is first on his own initiative, and then follows man's free acting through his collaboration, so that the merit of good works is to be attributed in the first place to the grace of God, then to the faithful. Man's merit, moreover, itself is due to God, for his good actions proceed in Christ, from the predispositions and assistance given by the Holy Spirit.
The "merit" that Catholics speak of, then, isn't absolute, but relative. It is like the merit of a child who helps his father clean up toys scattered all over the yard so that it can be mown. Does the child really deserve (absolutely merit) a treat for helping? Of course not. And yet the father, in his grace, freely chooses to associate the child with the father's work, and the merits that derive from it, including the ability to purchase ice cream.
This earned/unearned character of relative merit is most dramatically brought into relief by the case of the Immaculate Conception. The doctrine proclaims that in the first moment of her conception, before she had ever done anything either good or evil, God Chose to associate Mary most deeply with the work of her son and His Son, Jesus Christ, granting her the grace of freedom from the taint of original sin. Mary's association with her son's work of salvation, especially in her unconditional "Yes" to the will of God at the Annunciation, is the source of her merits. And yet these merits themselves are gifts of grace.
The Catholic position might be summarized as, "All is grace, and only therefore is there merit."