There are two things that, when combined, made it possible for this trick to exist. Here they are:
1. When creating the map for what Pokemon appear where, they made a crucial flaw. The 1-square-wide strip of water on the right side of Cinnabar and Seafoam Islands was programmed to be a place where wild Pokemon CAN appear. But (and thank GAMEFREAK for this one) they forgot to define what Pokemon can appear there. This wouldn't be that big of a deal, except that means the previous settings for "what Pokemon can appear" will remain, and if you read #2, you'll see why that causes the glitch.
2. When the Old Man catches the Weedle, they change the variables that are assigned to "Your Name" to Old Man, so it shows up as "Old Man threw the Poke Ball." Now, in order to do that, it overwrites the variables you gave to "Your Name". Therefore, the game must store the variables that make up your name to another place, so it can recall them later. So the programmers at NOA probably thought,
"What are some variables that we can overwrite to assign to the character's name for this process?"
"I got it! How about the slots that define what Pokemon you can run into?"
"That's it! Whenever the character enters a new area, they'll be rewritten, so it won't disturb the game at all!"
*points to #1* Umm.....no. As a result, that wonderful glitch can be yours for only *insert whatever price your local retailer charges for R/B*! Of course, it's not JUST Missingno. you can run into. There will also be some L100+ Pokemon, whose species and levels are determined by your name.