"in that place, time, or thing," Old English þærin; see there + in. Similar formation in German darin.
Entries linking to therein
there adv., conj.
Old English þær "in or at that place, so far as, provided that, in that respect," from Proto-Germanic *thær (source also of Old Saxon thar, Old Frisian ther, Middle Low German dar, Middle Dutch daer, Dutch daar, Old High German dar, German da, Gothic þar, Old Norse þar), from PIE *tar- "there" (source also of Sanskrit tar-hi "then"), from root *to- (see the) + adverbial suffix -r.
Interjectional use is recorded from 1530s, used variously to emphasize certainty, encouragement, or consolation. To have been there "had previous experience of some activity" is recorded from 1877.
in adv., prep.
a Middle English merger of Old English in (prep.) "in, into, upon, on, at, among; about, during;" and Old English inne (adv.) "within, inside," from Proto-Germanic *in (source also of Old Frisian, Dutch, German, Gothic in, Old Norse i), from PIE root *en "in." The simpler form took on both senses in Middle English.
Sense distinction between in and on is from later Middle English, and nuances in use of in and at still distinguish British and American English (in school/at school). Sometimes in Middle English shortened to i.
The noun sense of "influence, access (to power or authorities)," as in have an in with, is first recorded 1929 in American English. to be in for it "certain to meet with something unpleasant" is from 1690s. To be in with "on friendly terms with" is from 1670s. Ins and outs "intricacies, complications of an action or course" is from 1660s. In-and-out (n.) "copulation" is attested from 1610s.