The story
From the New Testament discourse of the Sheep and the Goats, particularly Matthew 25:32–33: “And before him shall be gathered all nations: and he shall separate them one from another, as a shepherd divideth his sheep from the goats: And he shall set the sheep on his right hand, but the goats on the left.”
Etymology from Wiktionary, CC BY-SA 4.0.