How to spell in-, is actually more difficult than it sounds. There are two in- prefixes used in English. One means not [as in incurable] and the other means in [as in incorporate]. They originally came from French and Latin, not Old English. However in English something complicated happened. These two prefixes got spelt several different ways, in-, im-, il-, ir- or sometimes even en-.
Which prefix spelling should one use? The general rule of thumb is to use the letter that matches the root word. The in- prefix was changed to match the first consonant of the root word. So il- is used in illegal, illiterate and illegible. The N and L sounds are both made in similar ways in the mouth. Words beginning with these sounds use the prefix in similar ways; these include N as in innumerable. However th- words usually use un- as in unthinkable and unthankful. (Rarely en- is used, for words with the in- meaning in, as in enthrone and enthral.) Continuing that pattern, im- is used in front of words that begin with the similarly formed M, P and B sounds, as in immodest, imbalance and impossible. The ir- form gets used before words beginning with R, such as irregular and irrevocable. However in- is not usually used before sounds such as sh, ch and j. These use un-; for example: unshakeable, unchecked and unjust.
Having different spellings of the same prefix has led to some pairs of similar words, even if the original root word is not English. The words enquire and inquire are both Modern English forms of the Old French enquerre. Originally it meant to ask. Today they are two spellings of the same word and one can use either without it being a mistake. However the enquire spelling is used more often for asking informal questions. The inquire spelling is often used for formal questions or investigations and is the more common spelling.
Rather than just memorise the spelling of each word on its own it is easier to note some patterns. Unfortunately these in-prefix spelling patterns get complicated. One has to know which of the two prefixes are being used, sometimes for a root word not used in English. Then these prefixes are spelt several different ways.