The forum post referenced in András's answer gives a quick overview of the the damage types but misses many important details about how those damage types are distributed.
Dragons contribute disproportionately to immunities for acid, cold, fire, lightning. That's because dragons generally come in good/evil pairs, and each dragon has 4 stat blocks (wyrmling, young, adult, ancient). So 8/10 lightning immunities are just different ages of blue and bronze dragons. On top of that metallic dragons are good - and thus unlikely to be fought - so in practice there's only 3 monsters with lightning immunities worth considering.
Among elementals, fire elementals contribute disproportionately to non-poison immunities: there's 9 kinds of fire elementals, and they're all immune to fire damage. Other than those, only Ice Mephits (cold) and Djinni (lightning, thunder) contribute immunities.
Fiends contribute a large amount of resistances and immunities to fire, cold, and to a lesser extent lightning. There's 11 devils, 13 demons and 4 yugoloths in the Monster Manual.
- 11/11 devils are immune to fire and resistant to cold (presumably so they can survive in the hot and cold layers of the Nine Hells).
- 12/13 demons are resistant to fire (the last one is immune)
- 11/13 are resistant to cold (the last two are immune)
- 13/13 resist lightning
- 4/4 yugoloths resist cold, fire, and lightning
- Night hags are resistant to cold and fire
- Hell hounds and nightmares are immune to fire
There's 6 kinds of Slaadi and they're all resistant to acid, cold, fire, lightning, and thunder. This makes sense, since they come from the chaotic plane of Limbo.
Incorporeal creatures (banshees, ghosts, poltergeists, shadows, shadow demons, specters, will-o'-wisps and wraiths) also resist acid, cold, fire, lightning, and thunder (along with non-magical weapon damage). A few of them are immune to cold rather than resistant. All except the shadow demon (which is still resistant) are immune to necrotic damage, and both shadow monsters are the only ones vulnerable to radiant.
Yogoloths and oozes round out the resistances and immunities to acid.
Undead, fiends, constructs, and true elementals make up the bulk of poison immunities. These are generally non-biological creatures that don't need food, drink, or sleep. By "true elementals" I mean the ones that are made up entirely of their element, as opposed to elementally-infused flesh-and-blood creatures like azers, salamanders, and genies.
Undead make up almost all resistances and immunities to necrotic damage, and many contribute to the cold resistance totals.
Constructs make up 6/10 of those psychic immunities (3 of those are golems). The rest are couatls, sphinxes and demiliches.
In short, resistances and immunities are distributed fairly predictably among large groups of similar monsters. Rather than thinking in terms of number of resistances or immunities, it's more practical to think in terms of monster types. It's also worth noting that cold, fire, and lightning resistances often happen together, but monsters that resist those types rarely resist force, radiant, psychic or - if the target isn't undead - necrotic damage. Acid is also a fairly good fallback, since it works on non-Yugoloth fiends and all undead other than the incorporeal ones.