Old English wiðinnan "within, from within," literally "against the inside," see with + in.
Entries linking to within
with prep.
Old English wið "against, opposite, from, toward, by, near," a shortened form related to wiðer, from Proto-Germanic *withro- "against" (source also of Old Saxon withar "against," Old Norse viðr "against, with, toward, at," Middle Dutch, Dutch weder, Dutch weer "again," Gothic wiþra "against, opposite"), from PIE *wi-tero-, literally "more apart," suffixed form of *wi- "separation" (source also of Sanskrit vi "apart," Avestan vi- "asunder," Sanskrit vitaram "further, farther," Old Church Slavonic vutoru "other, second"). Compare widow (n.).
Sense shifted in Middle English to denote association, combination, and union, partly by influence of Old Norse vidh, and also perhaps by Latin cum "with" (as in pugnare cum "fight with"). In this sense, it replaced Old English mid "with," which survives only as a prefix (as in midwife). Original sense of "against, in opposition" is retained in compounds such as withhold, withdraw, withstand.
Often treated as a conjunction by ungrammatical writers and used where and would be correct. First record of with child "pregnant" is recorded from c. 1200. With it "cool" is African-American vernacular, recorded by 1931. French avec "with" was originally avoc, from Vulgar Latin *abhoc, from apud hoc, literally "with this."
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.