According to Hindu mythology, how many times has Shiva opened his 3rd eye and why?
However, we know four instances where Mahadeva opened His 3rd eye, as per Puranas.
Incident 1: Burning of Kama (Kama Dahana)
When Shiva was doing Tapasya on Kaliasa, Parvathi was serving Mahadeva with permission of her father Himavat. As Tarakasura was tormenting Devas, they couldn't tolerate him and Indra wanted to ignite desires in Shiva, so that Shiva would marry Parvathi and their son would kill demon Taraka. Indra commanded Kama (with Rati) to go to Kailasa and asked him to inginte desires in Shiva.
तच्छिद्रं प्राप्य मदनः प्रथमं हर्षणेन तु। बाणेन हर्षयामास पार्श्वस्थं चन्द्रशेखरम्॥२५ ।।
Finding the weak point, Kamadeva who was present in the vicinity, shot an arrow named Harsana which delighted Siva.
शृङ्गारैश्च तदा भावैः सहिता पार्वती हरम्। जगाम कामसाहाय्ये मुने! सुरभिणा सह।२६।।
At that point of time Parvati went to Siva with emotions of love accompanied with spring.
After this Mahayogi (as a part of His divine Leela) praised beauty of Parvathi. He felt this as disgrace and saw His surroundings and found Kamadeva.
वामभागे स्थितं कामं ददर्शाकृष्टबाणकम्। स्वशरं क्षेमुकामं हि गर्वित मूढचेतसम्।।७।।
Then he spotted to his left the arrogant and foolish Kamadeva, who placing the arrow over the bow was about to shoot the arrow.
तं दृष्ट्रा तादृशं कामं गिरिशस्य परात्मनः। सञ्जातः क्रोधसम्मर्दस्तत्क्षणादपि नारद!।।८।।
Witnessing Kamadeva in that condition, O Nārada, Šiva, at once was enraged.
कामः स्थितोऽन्तरिक्षे स धृत्वा तत्सशरं धनुः। चिक्षेपास्त्र दुर्निवारममोघं शङ्करे मुने!।९।
O Narada, Kamadeva, while staying in the sky, shot his infallible arrow over Siva.
बभूवामोघमस्त्र तु मोर्घ तत्परमात्मनि।। समशाम्यक्ततस्तस्मिन्सङ्क्रुद्धं परमेश्वरे।।१०।।
The infallible arrow, shot at Siva, became futile, without displaying its might. It calmed down. At this Siva was enraged.
मोघीभूते शिवे स्वेऽस्त्रे भयमापाशु मन्मथः। चकम्पे च पुरः स्थित्वा दृष्ट्रा मृत्युञ्जयं प्रभुम्।।११।।
Finding the arrow shot by Kamadeva,getting infructuous, Kámadeva was terrified and started shaking looking at Siva.
सस्मार त्रिदशान्सर्वाञ्छक्रादीन्भयविह्वलः। स स्मरो मुनिशार्दूल! स्वप्रयासे निरर्थके।१२।।
Getting frightened, and becoming unsuccessful in his efforts, he started remembering Indra and other gods.
Even though other Devas were eulogizing Lord Shiva, he opened His 3rd eye and burned the Kama Deva to Ashes.
स्तुर्तिं कुर्वत्सु देवेषु क्रुद्धस्याति हरस्य हि। तृतीयात्तस्य नेत्राद्वै निःससार ततो महान्।।१४।। ललाटमध्यगात्तस्मात्स वह्निर्दुतसम्भवः। जज्वालोध्र्वशिखो दीप्तः प्रलयाग्निसमप्रभः।।१५।।
While the gods were so eulogising, Siva opened his third eye, which had been fixed in the middle of the forehead. At once the fire flame emerged from the same, which started rising up words like the fire of the time of dissolution.
भस्मसात्कृतवान्साधो ! मदनं तावदेव हि। यावच्च मरुतां वाचः क्षम्यतां क्षम्यतामिति।।१७।।
Before the gods could beg forgiveness from Siva, for Kama, the fire reduced Kamadeva to ashes.
Credits: Mrinal Rai on Deviant Art
Incident 2: Birth of Jalandhara
When Indra and Brihaspathi were going to Kalisa, Lord Shiva as a part of leela, went to them naked with matted hair and confronted them. Indra, who was haughty, argued with naked man and threatened to kill Him with Vajra.
Shiva enraged by Indra's behavior opened his 3rd eye. Just before opening 3rd eye, Brihaspathi identified Him as Lord Shiva and eulogized Him.
दृष्ट्रा बृहस्पतिस्तूर्णं प्रज्वलन्तं स्वतेजसा। पुरुषं तं धिया ज्ञात्वा प्रणनाम हरं प्रभुम्।। २० ।।
Then the naked ascetic who was none else than Siva himself, wearing the matted locks of hair over the head and was illumining with his own splendour, was recognised by Brihaspati who offered his Salutation to him.
कृताञ्जलिपुटो भूत्वा ततो गुरुरुदारधीः। नत्वा च दण्डवटूमौ प्रभु स्तोतुं प्रचक्रमे। २१।
The extremely wise Brihaspati, offered his salutation to him while prostrating before him. Then he started praying him.
Shiva then forgiving, directed fire towards ocean and Jalandara was born out it.
अथो शिवस्य तत्तेजो भारनेत्रसमुद्भवम्। क्षिसं च लवणाम्भोधी सद्यो बालत्वमाप ह।४।।
The fire emerging from the third eye of Siva, when thrown in the oceanic water, took to the form of an infant.
तत्र वै सिन्धुगङ्गायां सागरस्य च सङ्गमे। रुरोदोच्चैः स वै बालः सर्वलोकभयङ्कर:॥५॥
At the confluence of the Ganga and the ocean, the terrific child started crying aloud.
Incident 3 : Birth of Andhaka
Goddess Parvathi as a part of love sports, closed eyes of Great Lord from back and whole world became dark. Then lord Shiva opened His 3rd eye and fire emanated from it and blind creature (Andhaka) was born.
This story is mentioned in Rudra Samhita (Yuddha Khanda) Chapter 42 of Shiva Maha Purana.
स एकदा मन्दरनामधेयं गतो नगं तद्वरसुप्रभावात्। तत्रापि नानागणवीरमुख्यैः शिवासमेतो विजहार भूरि।। १५ ।।
Once he went to the Mandara mountain, to witness its excellent beauty, where also he sported with Pārvatī and other ganas.
पूर्वे दिशो मन्दरशैलसंस्था कपर्द्दिनश्चण्डपराक्रमस्य। चक्रे ततो नेत्रनिमीलनं तु सा पार्वती नर्मयुतं सलीलम्।। १६॥
In the eastern region of the Mandaracala mountain, Parvati playfully, closed both the eyes of Siva.
कराम्बुजाभ्यां निमिमील नेत्रे। हरस्य नेत्रेषु निमीलितेषु क्षणेन जातः सुमहान्धकारः॥ १७॥
Parvati closed the eyes of Siva, with her lotus like hands having the lustre of coral and the golden lotus. At the closing of the eyes of Siva, immense darkness spread everywhere.
तत्स्पर्शयोगाच महेश्वरस्य करौ च तस्याः स्खलितं मदाम्भः। शम्भोर्ललाटे क्षणवहितसो विनिर्गतो भूरि जलस्य बिन्दुः॥ १८॥
With the touch of the eyes of lord Siva with the hands of Parvati, the rapturous rutting juice emerged from her hands which became hot with the fire of his eyes on the forehead and flowed out in copious drops.
गर्भी बभूवाथ करालवक्त्रो भयङ्करः क्रोधपरः कृतघ्नः। अन्धो विरूपी जटिलश्व कृष्णो नरेतरो वैकृतिकः सुरोमा।। १९॥
A child emerged out of it. With an awful face, filled with rage, ungrateful, blind, crooked, black in colour, having a form different than a human, deformed and with many diseases.
This story might have happened in one of the previous Kalpas, probably during Sveta kalpa as Shiva Purana mentions mainly stories of Sveta Kalpa.
Andhaka was born from Diti in this Kalpa as mentioned in Harivamsa Parva of Mahabhartha.
Incident 4 : When Shiva sported with Parvathi
This is similar story to above but Andhaka was not born and this might have happened in Sweta Varaha Kalpa (Present kalpa) as this is mentioned in Mahabhartha.
The beautiful Uma, with smiling lips and desirous of playing a jest,covered from behind, with her two beautiful hands, the eyes of Mahadeva. As soon as Mahadeva's eyes were thus covered, all the regions became dark and life seemed to be extinct everywhere in the universe. The Homa rites ceased. The universe became suddenly deprived of the sacred Vashat also. All living creatures became cheerless and filled with fear.
Indeed, when the eyes of the lord of all creatures were thus closed, the universe seemed to become sunless. Soon, however, that overspreading darkness disappeared. A mighty and blazing flame of fire emanated from Mahadeva's forehead. A third eye, resembling another sun, appeared (on it). That eye began to blaze forth like the Yuga-fire and began to consume that mountain. The large-eyed daughter of Himavat, beholding what occurred, bowed her head unto Mahadeva endued with that third eye which resembled a blazing fire.
She stood there with gaze fixed on her lord. When the mountain forests burned on every side, with their Was and other trees of straight Trunks, and their delightful sandals and diverse excellent medicinal herbs, herds of deer and other animals, filled with fright, came with great speed to the place where Hara sat and sought his protection. With those creatures almost filling it, the retreat of the great deity blazed forth with a kind of peculiar beauty.
Meanwhile, that fire, swelling wildly, soared up to the very heavens and endued with the splendour and unsteadiness of lightning and looking like a dozen suns in might and effulgence, covered every side like the all-destroying Yuga-fire. In a moment, the Himavat mountains were consumed, with their minerals and summits and blazing herbs. Beholding Himavat crushed and consumed, the daughter of that prince of mountains sought the protection of the great deity and stood before him her hands joined in reverence.
There's another legend involving Shiva's 3rd eye, where Pippalada, partial avatar of Rudra, in order avenge his father Dadichi's death from Devas, did a tapasya for Shiva.
Shiva pleased with his tapasya manifested and asked him whether he could see his 3rd eye. Pipalada said he couldn't see His (Shiva's) 3rd eye. Shiva told him to do a tapasya til he could see His 3rd eye. Finally, Pippalada was able to see Shiva's 3rd eye and the very moment when He saw the 3rd eye, Demon was born to take revenge on Devas.
However, this story doesn't involve opening of Shiva's 3rd eye. This is mentioned in detail in Chapter 40 Gautami Mahatmya of Brahma Purana (Pg No -910).