When it comes to things like the difference between Peck, Horn Attack, and Megahorn, I believe that Pokedream and Circus are actually correct, and that the actual answer has to do with something called "Infinity Energy" which is mentioned in the later games and/or the anime. A move like Peck, even though on paper it might sound like it's doing nothing more in practice than "poke the opponent with a sharp thing," is in fact charged with Flying-type Infinity Energy, whereas Megahorn is an attack charged with Bug-type Infinity energy. I'm not clear on the details of this, but that's the impression I've gotten.
When it comes to what Pokemon learn what moves, the real answer, of course, is that Game Freak doesn't have time to examine a chart of every Pokemon versus every move to check that there are no "obvious" pairings that they have overlooked; they just need to hope that every case of an off-type move being highly appropriate for a certain Pokemon gets noticed by somebody somewhere down the line. It would be nice if they did, but I can understand why ain't nobody got time for that.
My favourite case of a Pokemon not learning a move that it really should, is the fact that Drowzee and Hypno do not learn Dream Eater by level up. They can learn it by TM in every game in which Dream Eater is a TM, but they should really learn it by level up as well; of the 898 Pokemon, nevermind the first 150, Drowzee should be #1 on a list of Pokemon that can learn a move called "Dream Eater."
There are a few amusing ones here:
https://www.youtube.com/watch?v=WV_fqgVXvW4 😄
Regarding one specific thing from that video, the fact that Levitate continues to protect against Earthquake even when the Pokemon is using Dig, strikes me as exactly the kind of thing that Game Freak
would program around - it's frankly right up there with Earthquake being able to affect Pokemon using Dig in the first place - but I assume they just haven't gotten around to noticing it.