Origins of negative prefixes like in-, un-, il-, ir-, dis-, a-
Solution 1:
The prefix in- can be assimilated: il- before an l; im- before b, m or p; ir- before r.
The prefix dis- is of Latin origin, where it had a privative, negative, or reversing force.
a- is the trickier of all, because it has many origins and variants (I learnt a lot reading the answers to the question linked). In the sense of “not” or “without”, a- comes from the Greek, where it had the same meaning.
Solution 2:
In English, a lot of words that mean somewhat of the same thing came about because they are from different roots. For example, Latin and German have contributed to the English vocabulary. The prefixes you mentioned have different etymologies as well. From the Oxford English Dictionary:
dis-
dis- Latin dis- was related to bis , originally *dvis = Greek δίς twice, < duo , δύο two, the primary meaning being ‘two-ways, in twain’.
In English, it is now used in the following way:
Hence, in English, dis- appears (1) as the English and French representative of Latin dis- in words adopted from Latin; (2) as the English representative of Old French des- (modern French dé-, dés-), the inherited form of Latin dis-; (3) as the representative of late Latin dis-, Romanic des-, substituted for Latin dē-; (4) as a living prefix, arising from the analysis of these, and extended to other words without respect to their origin.
un-
Representing Old English un- , = Old Frisian un- , on- , oen- (West Frisian ûn- , on- , East Frisian ûn- , North Frisian ün- ), Middle Dutch (and Dutch) on- , Old Saxon (Middle Low German, Low German), Old High German (Middle Low German, German), and Gothic un- , Old Norse ú- , ó- (Icelandic ó- , Swedish o- , Norwegian and Danish u- ), corresponding to Old Irish in- , an- , Latin in- (im- , il- , ir- , i- ), Greek ἀν- , ἀ- , Arm. an- , Sanskrit an- , a- , Indo-European *n̥ , an ablaut-variant of ne not
In English, un- is from Old English, and is used most often when new words are created.
in-
Latin in- adv. and prep., used in combination with verbs or their derivatives, less commonly with other parts of speech, with the senses ‘into, in, within; on, upon; towards, against’, sometimes expressing onward motion or continuance, sometimes intensive, sometimes transitive, and in other cases with little appreciable force.
So why have more than one? Because English is funny that way. All three prefixes were maintained over time, and are used to combine with different sets of words. So while un and in are similar, the latter is from Latin and the former is from Old English. For a bit more information on the difference, this article from World Wide Words notes:
There is a rule, but it’s only of value to somebody who knows which language the root word came from, so it’s really no help at all for most of us. In general, words take un- when they are of English (Germanic) origin and in- if they come from Latin. (The forms im-, il-, and ir- are variations on in-.) Apart from that, there’s really no good guide to which one you should choose. You’re just going to have to stick to learning them by rote.