It's not, actually. Some people thought it was, but apparently the creators had never heard of smegma before and it was just an unfortunate coincidence.
Lexicographer Tony Thorne, in his 1990 Dictionary of Contemporary Slang (ISBN 0-7475-2856-X), reports instances of "smeg" (and derivatives) being used as a term of "mild contempt and even affection" among "schoolboys, students and punks" as early as the mid-1970s — a decade or so prior to the inception of the Red Dwarf phenomenon — and claims unequivocally that the etymology of the term traces back to "smegma".
Actually several people already bothered to answer, their answers just haven't federated to your instance yet. One answer that just says "Red Dwarf" is already at 8 upvotes on my instance of Lemmy.