From svefn (“sleep”) + purka (“a miserable or a sleepy person”). The noun purka is a rare word which has quite a few other meanings in Icelandic such as “something of small height” (compare the Danish purk (“a small lad”) or the dialectal Swedish purka (“a short and chubby woman; sow; miser”)).
The oldest written example from the Orðabók Háskólans ("the University Dictionary") of the word svefnpurka is from a Latin-Icelandic dictionary, written and published in 1738 by Jón Árnason (is). There the given translation of the Latin word dormitor (from the Latin verb dormiō meaning "I sleep") is "svefnpurka" and "sísofandi". It is possible that Jón had in fact coined this compound himself as a myriad of Icelandic words in that dictionary are of his own concoction.