When one is made righteous and converted into a new creation through faith in the forgiveness of God apart from works they produce righteous works because of the new righteous nature they have received. Those righteous works is what God will use to judge us at the end of the age as having been made righteous (born again) through the forgiveness of sin, or not. Those who have the evidence that shows they are born again enter into the kingdom of God. Those who can't show by how they lived that they have the righteousness that comes by faith go to the left and into the eternal fire.
The works in the passage you quoted are the evidence of one's righteousness, the righteousness they received when they believed. They are not the works one must do in order to earn passage into the kingdom as a debt owed to the person who performed them. That is a works gospel. That is the gospel the Catholic church teaches.
Justification state of grace is by faith and baptism, not faith alone!
Merits: good works / virtues are meritorious!
We are members of Christ in his grace and filled with his spirit!
1 Corinthians 12:26
And whether one member suffer, all the members suffer with it; or one member be honoured, all the members rejoice with it.
1 Peter 4:13
But rejoice, inasmuch as ye are partakers of Christ's sufferings; that, when his glory shall be revealed, ye may be glad also with exceeding joy.
Religion is what man owes to God for having created him in His image and likeness!
To Christ for having redeemed him in His own blood!
to the Holy Spirit for sanctifying him in the sacraments of holy mother church!
it only Christ by His grace (merits of His blood passion and death) that we are enabled and empowered to actually be holy and righteous and all our actions
if we live by the spirit we put to death the deeds of the flesh
my grace is sufficient for you
Phil 4:13 I can do all things in Christ who strengthens me.
Jn 15:5 apart from me you can do nothing!
our participation is required
Matthew 16:24
Then said Jesus unto his disciples, If any man will come after me, let him deny himself, and take up his cross, and follow me.
Romans 8:17
And if children, then heirs; heirs of God, and joint-heirs with Christ; if so be that we suffer with him, that we may be also glorified together
2 Corinthians 12:9
And he said unto me, My grace is sufficient for thee: for my strength is made perfect in weakness. Most gladly therefore will I rather glory in my infirmities, that the power of Christ may rest upon me.
Phil 1:29
For unto you it is given in the behalf of Christ, not only to believe on him, but also to suffer for his sake;
Colossians 1:24
Who now rejoice in my sufferings for you, and fill up that which is behind (lacking) of the afflictions of Christ in my flesh for his body's sake, which is the church:
Titus 2:14
Who gave himself for us, that he might redeem us from all iniquity, (redemption) and purify unto himself a peculiar people, (justification / baptism notice purify / wash) zealous of good works. (Sanctification)