An image of Lord Shiva is incomplete without a snake coiled around his neck. The snake represents the Ahamkara (ego). When we poke a snake, it recoils instantly and spreads its hood to attack us. Similarly, when someone says something that we don't wish to hear, our ego spontaneously reacts. This ego lies inside the human body whereas, in the Gods and the Goddesses, the ego becomes powerless. It doesn't affect them because they govern it. Hence, Shiva uses this Ahamkara as an ornament because it doesn't find space within his body. The Lord monitors the Ahamkara or the ego that otherwise makes us hollow from within.
Shiva is also known as Bairagi (or Vairagi), meaning he is above the mundane world. He doesn't fear anything as he is above all emotions. A snake that is deadliest to us, is nothing but a harmless being for Shiva, who is invincible.
Another perspective of the snake around Shiva's neck projects his compassionate side. Since he is the Lord of the animals, he is kind enough to wrap a snake around his neck. This representation also highlights the universal belief of "live and let live".
Another legend throws light on a different aspect of Shiva's association with the snake. One school of thought believes that the snake represents the endless cycle of birth and death. And if one wishes to rid themselves from the vicious circle, then they must surrender to him with devotion and devoid of Ahamkara.
The coiled snake around Shiva's neck also reminds devotees to keep their ego under control. When the ego is in check, peace prevails in life forever.
Interestingly, Shiva is also known as ‘Nageshwar’, meaning Lord of the snakes. There are temples dedicated to this form of the Lord across the country.(Ref: Gayatri Lyer Mind and Soul)