1756, "special vocabulary of tramps or thieves," later "jargon of a particular profession" (1801). The sense of "very informal language characterized by vividness and novelty" is by 1818.
Anatoly Liberman writes here an extensive account of the established origin of the word from the Northern England noun slang "a narrow piece of land running up between other and larger divisions of ground" and the verb slanger "linger, go slowly," which is of Scandinavian origin (compare Norwegian slenge "hang loose, sling, sway, dangle," Danish slænge "to throw, sling"). "Their common denominator seems to be 'to move freely in any direction' " [Liberman]. Noun derivatives of these (Danish slænget, Norwegian slenget) mean "a gang, a band," and Liberman compares Old Norse slangi "tramp" and slangr "going astray" (used of sheep). He writes:
It is not uncommon to associate the place designated for a certain group and those who live there with that group’s language. John Fielding and the early writers who knew the noun slang used the phrase slang patter, as though that patter were a kind of talk belonging to some territory.
So the sense evolution would be from slang "a piece of delimited territory" to "the territory used by tramps for their wandering," to "their camping ground," and finally to "the language used there." The sense shift then passes through itinerant merchants:
Hawkers use a special vocabulary and a special intonation when advertising their wares (think of modern auctioneers), and many disparaging, derisive names characterize their speech; charlatan and quack are among them.
[Slang] is a dialectal word that reached London from the north and for a long time retained the traces of its low origin. The route was from "territory; turf" to "those who advertise and sell their wares on such a territory," to "the patter used in advertising the wares," and to "vulgar language" (later to “any colorful, informal way of expression”).
[S]lang is a conscious offence against some conventional standard of propriety. A mere vulgarism is not slang, except when it is purposely adopted, and acquires an artificial currency, among some class of persons to whom it is not native. The other distinctive feature of slang is that it is neither part of the ordinary language, nor an attempt to supply its deficiencies. The slang word is a deliberate substitute for a word of the vernacular, just as the characters of a cipher are substitutes for the letters of the alphabet, or as a nickname is a substitute for a personal name. [Henry Bradley, from "Slang," in Encyclopedia Britannica, 11th ed.]
A word that ought to have survived is slangwhanger (1807, American English) "noisy or abusive talker or writer."