late 14c., metathesis of Middle English thrittene, from Old English þreotene (Mercian), þreotiene (West Saxon), from þreo "three" (see three) + -tene (see -teen). Similar formation in Old Saxon thriutein, Old Frisian thretten, Dutch dertien, German dreizehn, Old Norse threttan, Swedish tretton. As a noun from late Old English.
Not an unlucky number in medieval England, but associated rather with the customary "extra item" (as in baker's dozen). Superstitions began with association with the Last Supper, and the unluckiness of 13 sitting down together to dine (attested from 1690s). Most of the modern superstitions (buildings with floor "12-A," etc.) have developed since 1890.