Scripture teaches both justification by faith and judgement according to works. That seems prima facie inconsistent. If the sins of Christians have been forgiven by grace alone, what's the basis for judgment according to works?
Because Scripture itself does not detail how to harmonize these two facts, theologians are left to speculate.
i) The word "judgment" is ambiguous. It can't mean those who've been justified will be condemned.
ii) Here's my own suggestion: As sinners, we suffer from moral blindspots. Sin itself renders us oblivious to some of our sins. One possible purpose for judgment according to works might be to make us cognizant of wrongdoing in cases where we were unaware of our own wrongdoing.
iii) On a related note, to be conscious of your sins makes you more appreciative of God's gracious forgiveness.