"in or within which or what," early 13c., from where (in the sense of "in which position or circumstances") + in. Similar formation in Dutch waarin, German worin, Swedish vari, Danish hvori.
Entries linking to wherein
where adv.
Old English hwær, hwar "at what place," from Proto-Germanic adverb *hwar (source also of Old Saxon hwar, Old Norse hvar, Old Frisian hwer, Middle Dutch waer, Old High German hwar, German wo, Gothic hvar "where"), equivalent to Latin cur, from PIE root *kwo-, stem of relative and interrogative pronouns. Where it's at attested from 1903.
It has figured in a great many prepositional and adverbial compounds through the years; in addition to the ones listed in this dictionary (whereas, wherefore, whereabouts, etc.) English has or had whereagainst, wherefrom, wherehence, whereinsoever, whereinto, wheremid, whereout, whereover, whereso, wheresoever, wherethrough, whereto, whereunder, whereuntil.
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.