Secondly, works are not being prescribed as criteria for salvation in this passage. Rather, they provide descriptions of who belongs in either one of two categories: sheep or goats.
The former group experienced genuine conversion of heart which results in the performance of good works, whereas those in the latter group simply did not care for the things of God.
Jesus Christ was addressing matters from a general standpoint, not giving specific ordinances or rituals that we must observe in order to earn God's favor. The Lord points to our works in judgement because they serve as convictable evidence of our obedience to Him.
There is an element of grace alone present in this context ("...blessed by My Father...", Matthew 25:34). The kingdom of heaven was prepared by God as a result of His kindness and mercy. This inheritance was prepared for us long before we were even born ("before the foundation of the world"). This is clearly not a matter of earning our way into heaven by good works. The concept of faith alone ties in with grace (Romans 4:16).
God will certainly reward believers for their good deeds. On the other hand, the reception of eternal life is a free gift that He gives. The works that we do perform are a result of His divine grace. Justification is not by works of righteousness which we have done (Ephesians 2:8-9). We are to place our trust in Christ's work alone for salvation.