I don't know much about music genres, so forgive me if this question is stupid, but I find that the major General's Song has many aspects of modern rap music, and judging by the comments on the different videos of this song, I am not the first to make this connection, so I wonder if this could be considered an early song of this genre, although of course rap music would mature much later.
This is why I think this song is rap-like:
The character is supposedly improvising the rhymes on the fly, something that rappers actually do sometimes
The performer demonstrates his ability of reciting the whole song very fast, something that would also become a staple of rap music
The author makes reference and mocks his own work "And whistle all the airs from that infernal nonsense Pinafore". Rappers don't usually mock their own works because they are not comedians but they do often make references to their other work
Also, what does it mean when the lyrics say:
"For my military knowledge, though I'm plucky and adventury,
Has only been brought down to the beginning of the century"
what happened at the begging of that century (1800's) that "brought down military knowledge"?
There are several important elements of hip hop/rap music that the Major General's Song is missing- the DJ, the samples, the actual improvisation. But what's more important is that the song is only the most popular example of its own style: the patter song. As such, it's got more in common with The Music Man than it does the Sugarhill Gang.
The patter song as we know it was popularized by and became synonymous with playwright W.S. Gilbert and composer Arthur Sullivan. The form is indebted to rhythmic solos from light opera and Italian theater; it became its own form with late-19th century comic operas. Both contemporary critics and modern academics also acknowledge the influence of the popular ballad on Gilbert's lyrics. Before becoming a lyricist, Gilbert was a contributor and theater critic with the Fun magazine. Here he wrote comical ballads under the name "Bab." They copied the structure of mass-printed ballads, with quaint narratives of adventurers, gentlemen, and maidens. However, they are not so much satirical in their content as they are broadly comic and irreverent. Just read Gilbert's preface to the collected edition, subtitle "Much Sound and Little Sense," to get an idea of the humor. Several would inspire the plots of later operas.
A prototype for the patter song form can be seen in G & S's first collaboration, Thepsis, whose plot of an acting troupe taking over for the Olympian gods is highly original:
I once knew a chap who discharged a function
on the north south east west Diddlesex junction
he was conspicuous exceeding,
for his affable ways and his easy breeding.
Although a chairman of directors,
he was hand in glove with the ticket inspectors,
he tipped the guards with brand-new fivers,
and sang little songs to the engine drivers.
'Twas told to me with great compunction
by one who had discharged with unction,
a chairman of directors' function,
on the north south east west Diddlesex junction.
This song was "the hit of the night" per The Sunday Times and the Daily Telegraph observed that "though the ditty was long, the audience would have been well content to hear it all over again" while noting its similarity to the Bab ballads (as quoted in Bradley). Sadly, Sullivan's score for this first work has been lost. Some argue it used the same tune as the Major General's song, since other texts and melodies from Thepsis were re-used in Pirates of Penzance. But from the text we can see elements of the style from the beginning of the Gilbert and Sullivan parternership: polysyllable rhymes, a simple lilting meter, nonsensical words, and a short refrain repeated by a chorus (here in italics).
The Gilbert and Sullivan opera formula wouldn't crystallize until their third opera, The Sorcerer. The opera's plot is typical comic opera fair (love potions, star-crossed lovers, and comedies of errors) and it lives in shadows of its successor, HMS Pinafore, that brought G & S enormous fame. It was an important moment for the G&S patter song, though, because it brought baritone George Grossmith into the G&S company. Grossmith had a background in stage comedy, unlike most opera performers, who were vocalists first and actors second. In his autobiography, A Society Clown, Grossmith recounts his excitement and anxiety at receiving a letter from Sullivan asking him to be in a new show, as well as his first official meeting with G&S:
I saw that the part would suit me excellently, but I said to Mr. Gilbert, "For the part of a Magician I should have tought you required a fine man with a fine voice."
I can still see Gilbert's humorous expression as he replied, "No; that is just what we don't want."
Grossmith was the perfect self-depricating skillful comic that G & S needed. He originated the title role in the The Sorcerer, the Major General in Pirates, and a string of other characters in the same archetype, each with their own patter song.
We must also view Gilbert and Sullivan as part of broader trend, what Carolyn Williams calls the "Victorian efflorescence of comic and nonsense verse." Stage performances were increasingly accessible in the US and England in the later 19th-century. English music halls boomed in the 1860s, and in the 1880s American Vaudeville collected and formalized popular live acts in one show. This was accompanied by a rapid increase in print media (most importantly, humor magazines and sheet music) and a growing urban population. Meanwhile, the Aesthetic movement emerged at odds with the social commentary and broad comedy of these popular forms and entertainment. Americans might most recognize it as the architectural and decorative style of the Gilded Age; poets, novelists, and artists also aligned themselves with it. Aestheticism valued "art for art's sake," a connection with local flora and fauna, and a sense of elevation from the social problems of the era.
If you're a comic like Gilbert and Sullivan, the Aesthetics were exactly the kind of snobs you'd want to punch in the face. And that's exactly what they did. It was a sort of "vicious cycle" in which the mockery of Aestheticism led to snobbery which led to more mockery. But whereas this mockery and absurd humor could be found in most any form of popular media, Gilbert and Sullivan were recognized as the best at it.
In fact, the entire G&S opera Patience is a pointed critique of Grossmith played the Aesthetic poet Bunthorne; he's still instantly as someone mocking a stuck-up poet. The patter he sings he takes seriously, but comes off as a clear satire:
If you're anxious for to shine in the high aesthetic line as a man of culture rare
You must get up all the germs of the transcendental terms, and plant them everywhere.
You must lie upon the daisies and discourse in novel phrases of your complicated state of mind,
The meaning doesn't matter if it's only idle chatter of a transcendental kind.
And every one will say, As you walk your mystic way,
"If this young man expresses himself in terms too deep for me, Why, what a very singularly deep young man this deep young man must be!"
So while the deprecation and mockery of Pinafore in the Major General's is certainly a stand-out line, it's very much part of this Victorian brand of humor.
As for your second question, it's important to note that it's "my military knowledge." A main joke of the song is that the Major General knows all kinds of things- but his military knowledge "has only been brought down to the beginning of the century," that is, he hasn't learned about anything after 1800!
Bradley, Ian C. The Complete Annotated Gilbert and Sullivan. Oxford University Press, 2016.
Williams, Carolyn. “Parody and Poetic Tradition: Gilbert and Sullivan’s ‘Patience.’” Victorian Poetry 46, no. 4 (2008): 375–403.