THE SAVIOUR EXPLAINS WHY HE IS REWARDING HIS SHEEP.
"For I was an hungred, and ye gave me meat: I was thirsty, and ye gave me drink: I was a stranger, and ye took me in: naked, and ye clothed me: I was sick, and ye visited me: I was in prison, and ye came unto me," verses 35-36.
These words do not set down WHY they gained heaven, but rather is descriptive of their characters and how they lived, and are testimonies and evidences of the grace of God in them. Here is proof that they were the blessed of His Father, having His special grace bestowed upon them and that they were the children of God.
We do not get to heaven by our works! This is the devil's lie and is the foundation of all false religions. "For by grace are ye saved through faith; and that not of yourselves: it is the gift of God: not of works, lest any man should boast," Ephesians 2:8-9.