in- (1) Look up in- at
word-forming element meaning "not, opposite of, without" (also im-, il-, ir- by assimilation of -n- with following consonant, a tendency which began in later Latin), from Latin in- "not," cognate with Greek an-, Old English un-, all from PIE root *ne "not" (see un- (1)).

In Old French and Middle English often en-, but most of these forms have not survived in Modern English, and the few that do (enemy, for instance) no longer are felt as negative. The rule of thumb in English has been to use in- with obviously Latin elements, un- with native or nativized ones.
in- (2) Look up in- at
element meaning "into, in, on, upon" (also im-, il-, ir- by assimilation of -n- with following consonant), from Latin in- "in" (see in).

In Old French (and hence in Middle English) this often became en-, which in English had a strong tendency to revert to Latin in-, but not always, which accounts for pairs such as enquire/inquire. There was a native form, which in West Saxon usually appeared as on- (as in Old English onliehtan "to enlighten"), and some of those verbs survived into Middle English (such as inwrite "to inscribe"), but all now seem to be extinct.

Not related to in- (1) "not," which also was a common prefix in Latin, causing confusion: to the Romans impressus could mean "pressed" or "unpressed;" inaudire meant "to hear," but inauditus meant "unheard of." The trouble has continued in English; the hesitation over what is meant by inflammable being a commonly cited example. Implume (1610s) meant "to feather," but implumed (c. 1600) meant "unfeathered." Impliable can mean "capable of being implied" (1865) or "inflexible" (1734). Impartible in 17c. could mean "incapable of being divided" or "capable of being imparted." Impassionate can be "free from passion" or it can mean "strongly stirred by passion." Inanimate (adj.) is "lifeless," but Donne uses inanimate (v.) to mean "infuse with life or vigor." In addition to improve "use to one's profit," Middle English also had a verb improve meaning "to disprove" (15c.). To inculpate is "to accuse," but inculpable means "not culpable, free from blame." Infestive has meant "troublesome, annoying" (1560s, from infest) and "not festive" (1620s). In Middle English inflexible could mean "incapable of being bent" or "capable of being swayed or moved." In 17c., informed could mean "current in information," formed, animated," or "unformed, formless" ("This was an awkward use" [OED]). Inhabited has meant "dwelt in" (1560s) and "uninhabited" (1610s); inhabitable likewise has been used on opposite senses, a confusion that goes back to Late Latin.