Okay, so here's why and when Missingno. shows up:
Firstly, and kind of obviously, every time you enter a new area, the game loads up the encounter charts for that area, for land encounters, Surfing encounters, and fishing.
However, generally, towns don't have wild Pokémon in them, so they generally don't bother updating the land encounter charts when entering most town areas.
When you speak to the old man and get the tutorial on how to catch Pokémon, the game actually changes your name to "OLD MAN" temporarily in order to display the proper message text in the demo battle. However, it needs to store your name somewhere so it can recall it once the demo battle is concluded, and the land encounter table isn't currently in use since you're in a town, so it stores it there. It restores your trainer name before you regain control, so there's no risk of losing it, and the encounter table values will just get overwritten with the appropriate encounter chart when you go to any area land encounters would take place, so there shouldn't be any problem, right?
Well, as we've been seeing for some twenty years now… not quite.
See, Cinnabar Island, like most towns, has no grass tiles, and therefore no defined land encounter chart. When you go there, the land encounter chart isn't updated, since there's nothing to update it
to. However, the sea tiles just along the West coast, the final column of tiles in that direction before you exit Cinnabar Island entirely, are set to allow random encounters to happen, but not the expected Surfing random encounters. No, they're flagged as allowing
land random encounters to happen, so they draw from the land encounter table.
Which hasn't been updated since your player name was stored there.
As a result, the game takes the numerical IDs of the characters you inputted for your name, stored in two-digit hexadecimal format, and reads them as wild Pokémon species IDs and levels, instead, which is why you get such bizarre and seemingly-random assortments of Pokémon when you do this, and why which ones you find are based on your name. However, rather than 0~99 as in standard decimal, the values represented by two digits in a hexadecimal numbering range from 0~255 (or 1~256), and there are only 151 valid species of Pokémon in RGBY. So, what happens when the game tries to load an encounter with a Pokémon with a species ID that doesn't correspond to any of those?
Missingno. is what happens.
Or 'M.
Or a number of other wacky glitch Pokémon you can find if you're really determined.
Missingno. and 'M, however, are actually relatively harmless. Aside from just generally being bizarre in nearly every way the Generation I Pokémon games allow for, the only glitches they cause are either beneficial—setting the quantity of the sixth item in your bag to 128 or 256—or purely cosmetic, like making your Hall of Fame data all weird. No such promises about the other glitch Pokémon, unfortunately, but thankfully none of them correspond to any value that matches any of the letters you can enter for your name, so you very much have to go out of your way to encounter them.
To assuage any concerns, there is no area where you can just encounter Missingno. or other glitch Pokémon randomly without doing anything special; any circumstances under which you would encounter such a Pokémon would be ones you have to deliberately set up.
Edit:
Here's an excellent video detailing how and why the Missingno. glitch works with visuals and audio!~