In Matthew, Jesus is the judge of the righteous and the unrighteous. Jesus puts the righteous on his right, and the unrighteous on his left. The righteous people are good because they help clothe, feed, care, and visit those in need. The unrighteous don't help the needy and thus are separated from Jesus.
I heard about a newspaper staff who took a poll of their readers. They discovered that only four percent of their readers believed they didn't deserve to go to heaven. Twenty percent, however, knew other people whom they thought should not go to heaven.
It seems to me that none of us really deserve to be apart of God's heavenly kingdom. We have all neglected the poor, the sick, and the imprisoned. Some people even like to misuse the image of Jesus as judge to scare us over our lack of concern and help for others. But, seeing Jesus as a judge reminds us of our need for grace and forgiveness. We are sheep who have gone astray, but Jesus is the righteous judge who makes us righteous in the sight of God.