Old English in (prep.) "in, into, upon, on, at, among; about, during;" inne (adv.) "within, inside," from Proto-Germanic *in (cf. Old Frisian, Dutch, German, Gothic in, Old Norse i), from PIE *en "in" (cf. Greek en, Latin in "in, into," Old Irish in, Welsh yn-, Old Church Slavonic on-). As an adjective from 1590s.
The forms merged in Middle English. Modern sense distinction between in and on is from later Middle English. Sense of "holding power" (the in party) first recorded c.1600; that of "exclusive" (the in-crowd, an in-joke) is from 1907 (in-group); that of "stylish, fashionable" (the in thing) is from 1960. The noun sense of "influence, access" (have an in with) first recorded 1929 in American English. In-and-out "copulation" is attested from 1610s.