I think the main reason for the Bug-types' terribleness is that the Bug type serves as an introductory type of Pokémon. Catching bugs is the simplest kind of animal acquisition (for the lack of a better word), they are popuar to collect, their weaknesses are very intuitive, and the metamorphosis phase many bugs go through is an excellent way to showcase evolution. Another perk is that they fit nicely into the early-game type chart. They also have the gimmick of evolving fast, becoming strong Pokémon very early on, but they are outclassed later.
Basically, the Bug types serve to teach the concept of Pokémon in a nutshell. They display strenghts/weaknesses beyond the simple rock-paper-scissors model of the starter types, they showcase evolution very early on, and bug catching is something kids can easily relate to. Basically, they are the ideal early-game Pokémon.
That implies, however, that they are designed to be outclassed later in the game. In the competitive scene, all Pokémon are seen alongside each other, and the early-game bugs stand out as pretty bad. But in-game, Bug types are presented to you early on, where they are comparatively stronger than most of your other options. A little investment in training, and bam! You get that sweet Butterfree who can sweep the floor with Brock using only Confusion. Bug types are good at their stage of the game. However, the game designers want you to explore the options the game gives you, and that means that the first Pokémon you acquire shouldn't be strong enough to serve your needs throughout the entire game. Sooner or later, you will have to ditch a few of your early captures, to make room for a much stronger Pokémon caught in the mid-game. The Bugs are usually the first to go here.
This means that the game roster will be filled by a fair few weak Bug Pokémon. The games need to have some Pokémon used for introducing players to various types, and the Bug types fit that role like a glove. Later in the game, the type can return with more creative or outlandish designs, mimicking rarer or more powerful bugs of the kind you can't just find in any backyard forest. These are more exotic designs, with interesting secondary typings and enough power to stand up to the rest of the Pokémon in the game. However, these "special" Bug types will usually be outnumbered by the abundance of early-game introductory Pokémon. When you put all the Bug types up alongside each other, you will notice the bad bunch first, to a much larger degree than other types.
Of course, there are also the likes of Ledian and Ariados, that suck no matter when you get them in-game. I suppose those are used to teach players that there will always have to be some Pokémon worse than the others, no matter what you compare them to. Every barrel has to have a bottom, after all.