Lord Shiva wears snakes as his ornaments as well as for his Yajnopavitam (sacred thread). The snake Vasuki which often encircles neck of Lord Shiva can also work like Agni tatwa (fire element) for the Soma tatwa (moon) which is on the head of Lord Shiva. Thus by combining Agni and Soma, Amrita (immortal nectar) is produced which bathes Shiva. Now let's see all these things in scriptures:
- Snakes as ornament and sacred thread:
In the Skandha Purana, Kedar Khanda chapter 22, there is a description of form of Shiva. The verses which are relevant to the snakes are as:
यज्ञोपवितविधिना उरसा बिभ्रंत वृतम्॥
वासुकिं सर्पराजं च कंबलाश्वतरौ तथा॥ २२.३ ॥
कर्णद्वये धारयंतं तथा कर्कोटकेन हि॥
पुलहेन च बाहुभ्यां धारयंतं च कंकणे॥ २२.४ ॥
सन्नृपुरे शङ्खकपद्मकाभ्यां संधारयंतं च विराजमानम्॥
कर्पूरगौरं शितिकंठमद्भुतं वृपान्वितं देववरं ददर्शुः॥ २२.५ ॥
तदा ब्रह्मा च विष्णुश्च ऋषयो देवदानवाः॥
तुष्टुवुर्विविधैः सूक्तैर्वेदोपनिपदन्वितैः॥ २२.६ ॥ (Kedar Khanda chapter 22)
As a sacred thread he was wearing Vasuki, the king of serpents, as well as the Nagas Kambala and Asvatara on his chest.
Karkotaka was worn by him in the ears as ear-rings and Pulaha as bangles round his arms. He appeared brilliantly shining with
Sankhaka and Padmaka as his anklets. Suras saw the blue-throated mysterious lord, the most excellent one among Devas, white in complexion like camphor and accompanied by the bull.Then Brahma, Vishnu, the Sages, Devas and Danavas eulogized him with various hymns from the Vedas and the Upaniṣhads.
So, it is clear from above verses that Lord Shiva is wearing various serpents as his ornaments as well as the snake Vasuki as his sacred thread.
- Vasuki snake as Agni tatwa to the Soma (moon) on head:
The heat produced from the Vasuki snake which encircles neck of Lord Shiva can also cause the Soma (moon) element to exude Amrita (Immortal nectar) which then bathes Lord Shiva. In the Padma Purana Uttara Khanda chapter 10, we witness one such incident. The relevant verses are as:
एवं वदति संप्राप्तौ सुतौ स्कंदविनायकौ || २६ ||
तस्मिन्काले देवदेवो यतवागंगमर्दनम् |
चकार च करैर्व्यस्तैर्वासुकिर्भूतलेऽपतत् || २७ ||
हेरंबवाहनस्याखोः पुच्छं ग्रस्तमथाहिना |
स्वपत्रं ग्रस्तमालोक्य मुंचमुंचेत्युवाच ह || २८ ||
अत्रांतरे स्कंदवाहं क्षुब्धं वीक्ष्य महास्वरम् |
तद्भयाद्वासुकिर्ग्रस्तमाखुपुच्छमथोद्गिरत् || २९ ||
अथारुह्य हरस्यांगं गलमावेष्ट्य संस्थितः |
तस्य निश्वासपवनैरथ जातो हुताशनः || ३० ||
तस्योष्मणा चंद्र लेखा जटाजूटाटवी स्थिता |
सार्द्रतां तु तदा सायात्प्लावितं तद्वपुर्यथा || ३१ ||
तस्याह्यमृतधाराभिर्ब्रह्ममस्तकमालिका |
हरमौलिकपालानामभूत्संजीविता तदा || ३२ ||
पपाठ पूर्वमभ्यस्तं सर्वयोगश्रुतिक्रमम् |
श्रुत्वा परस्पराधीतं विवदंति शिरांस्यथ || ३३ || (Padma Purana 6.10)
When he was speaking like this, the two sons of Shiva, Kartikeya and Gajanana came there. At that time, the god of gods was massaging his body with his hands. Due to his hands being tossed about, Vasuki fell on the ground. Then the serpent Vasuki seized the tail of the mouse, the vehicle of Gajanana (Ganesha). Seeing his vehicle seized, he said: "Leave it, leave it." In the meanwhile, seeing the agitated vehicle, of a large note, of Skanda, Vasuki ejected, through his fear, the tail of the mouse, which he had seized; and then mounting upon Shiva's body, he encircled his neck and remained there. Due to its heat, the crescent moon remained in the forest of his matted hair. She (i.e. the crescent moon) then became wet, and bathed his body with Amrita (ambrosia); the row of the skulls on Shiva's head was brought back to life. And they recited all the sacred texts in due order, which they had formerly studied. The heads, hearing recital (of the sacred text) done by one another, discussed it.
Thus, in the above story it is clear that heat generated from Vasuki caused the Soma (moon) on the Shiva's head to exude Amrita (immortal nectar) which bathed Lord Shiva. Due to the effect of Amrita even the skulls which Lord Shiva was wearing came back to life and began to recite sacred texts.