the letter is a late modification of Roman -i-, originally a scribal creation in continental Medieval Latin to distinguish small -i- in cursive writing from the strokes of other letters, especially in the final positions of words. But in English, -y- was used for this, and -j- was introduced c.1600-1640 to take up the consonantal sound that had evolved from -i- since Late Latin times. This usage first was attested in Spanish, where it was in place before 1600. English dictionaries continued to lump together words beginning in -i- and -j- until 19c., and -j- formerly was skipped when letters were used to express serial order.
Used in modern writing to represent Latin -i- before a, e, o, u in the same syllable, which in Latin was sounded as the consonant in Modern English you, yam, etc., but the custom is controversial among Latinists: