Of uncertain origin.
Burrow derives the root from an earlier form *स्लग्न (slagna), *स्रग्न (sragna), and connects it to *स्रक (sraka, “wreath, garland”), which is usually attested as स्रज (sraja). Mayrhofer tentatively favors these hypothetical proto-forms, though seems to have rejected their connection to स्रज (sraja) by the time of writing the EWAia. He does not, however, propose a particular Indo-European root that the Sanskrit would trace back to.[1][2]
The root that most closely matches formally is Proto-Indo-European *(s)leg- (“to tire out, slacken”), with semantic shift "to be limp, slack" > "to 'lazily' cling onto" (perhaps in a similar way to how dripping slime tends to not separate easily) > "to adhere". If from this root, then cognate with Latin langueō, Ancient Greek λᾰ́γνος (lắgnos), and Proto-Germanic *slakaz (whence English slack). However, the semantic shift required for this is far from trivial.
Another phonetically similar root is Proto-Indo-European *(s)leh₂gʷ- (“to seize, latch onto”), whence Ancient Greek λάζομαι (lázomai, “to seize, grasp”) and Old English læċċan (whence English latch). This is semantically attractive, as well as temporospatially so given the root's attestation in both an eastern and western branch of Indo-European. However, Indo-European *-eh₂- should become आ (ā) in Sanskrit, while the root displays only a short vowel अ (a) in its various forms. That said, some relatives in modern Indo-Aryan, like Nepali लाग्नु (lāgnu, “to be attached”), show a long ā vowel, lending some feasibility to the derivation.
Older theories tentatively connected the root to रज् (raj), रञ्ज् (rañj, “to redden, dye”); under this derivation, रज् (raj) took on a more specific sense from "to attach" > "to attach color (i.e. to dye)". This is semantically tenuous and without textual evidence. Other theories connecting the word to लक्ष् (lakṣ, “to recognize; mark”) are similarly unconvincing.
It is also worth noting that the root bears a very strong semantic similarity to Proto-Indo-European *leyǵ- (“to bind”), whence English ligand. However, the phonetics are mismatched, particularly the palatal *ǵ in the Proto-Indo-European root, and would have to be sufficiently explained, in addition to the existence of *leyǵ- being under question.