Nintendo and Gamefreak used (pixel-variety) MissingNos instead of Pokemon while programming the game. They were left in because they thought nobody would be able to get to them (without Gameshark/etc). Ghost/Fossil MissingNos are needed in the game for the ghost/fossil sprites. All the other glitches are just elements of the game represented as Pokemon (with 'M having Pixel MissingNo's game elements).
The Egg glitch is needed in the game for the egg sprite. ????? are just filling up the unused hex slots in the game (with many glitchy effects).
The Bad Egg is needed for the Third Generation Egg Sprite (same as Emerald/FireRed/LeafGreen). ?????????? is the Pokemon used when programming (and is needed for the 'empty Pokedex' sprite). ? is in the game because presumeably, ?'s sprite was the 'empty Pokedex' sprite in beta versions of the game.
The only glitch that's sprite is used in these games is Bad Egg (for the Third Generation Egg Sprite). ?????????? (or ????? as it is known in Japanese versions of the game) was probably used in programming (there is no 'empty Pokedex' sprite in these games). Whether ? is in the games or not is unknown.
The only 'usuable' glitch in this game is Bad Egg (needed for (surprise, surprise) the Third Generation Egg Sprite). ?????????? freezes the game and it is not known if ? is in the game.
There you are, my theory on glitches in all Pokemon games, whether First, Second or Third Generation.
Edit 1: Edited to comply with Abwayax's wishes (? instead of ??))