Why Do Silkworms Make Silk
Silk is extracted from cocoon. Silkworms produce cocoon to protect the pupating larva, keeping the larva dry. And silkworm cocoons offer a little in the way of camouflage. The cocoon-encased pupa is probably less appetizing to potential predators (mostly birds) than a naked pupa would be.