Sans: Why didn't the skeleton go to the party?
Papyrus: Because he looked like me.
Sans: Sure.
Alright listen up, nimrod. The joke is that Sans asks why the skeleton didn't go to the party. Papyrus thinks it's because he "looked like" him (implying he's ugly or something). Then Sans says "sure" which means the real reason is something else. It's funny because it subverts expectations! You probably smell bad, by the way.