A spoilsport is a person who ruins other people's fun. You know: the girl shushing everyone at a sleepover party, the kid who refuses to play when it comes their turn to be "it."
Back before it meant organized athletics, sport meant games or joking. Instead of making fun of someone, you'd be "making sport" of them. So someone who spoils or wrecks the fun or sport of others is a spoilsport. Calling someone a spoilsport, though, is often just a way to pressure them to do something everyone knows is wrong.