1897, from German Lumpenproletariat, coined by Marx, who used it in the sense of "the rabble, poorest of the working class," "who make no contribution to the workers' cause" [OED]. From German lump "ragamuffin," which is related to lumpen "a rag, tatter," probably ultimately related to English lump (n.). With proletariat.
Marx used it first, apparently, in 1850 in German newspaper articles collected and republished in 1895 as "Die Klassenkämpfe in Frankreich 1848-1850." Its secondary sense of "boorish, stupid people" led to lumpen- being taken as a word-forming element meaning "unenlightened."