The exact origin of 13's status as an unlucky number is unclear. Some possibilities are Judas's arrival at the Last Supper, the occasional occurrence of calendar years with 13 full moons, or its status in the Sumerian numerical system.
Judas Iscariot, the apostle who betrayed Jesus, was the 13th to arrive at the Last Supper. In Norse mythology, Loki was also the 13th to arrive at a dinner party in Valhalla which led to the creation of evil in the world.
The Sumerian numerical system, which is still used for counting time, held that 12 was the most perfect number. By extension, 13 may have been considered unlucky since it was immediately after it. A 13th full moon also occurs every three or four years, which disrupted the arrangement of religious festivals in the Middle Ages.
Friday the 13th may be specifically considered unlucky because it was the day on which King Philip IV of France ordered the arrest of the Knights Templar, leading to the deaths of many of them.
Nathaniel Lachenmeyer, who wrote a book on the subject called "13," cites a tradition of not sitting 13 people around a dinner table for fear that the 13th would die. This tradition may also be related to the Last Supper.