Wikipedia
Tripurasura ( Sanskrit: त्रिपुरासुर) is a collective name given to the three demons Vidyunmali, Tarakaksha and Viryavana, who were sons of the demon Tarakasur. These three began to perform tapasya. For a hundred years they meditated standing only on one leg. For a thousand more years they lived on air and meditated. They stood on their heads and meditated in this posture for yet another thousand years.
Brahma was pleased at this difficult tapasya. He appeared before them and said, "What boon do you want?" "Make us immortal", answered Tarakasura’s sons. "I can’t make you immortal", replied Brahma. "I don’t have the power. Ask for something else instead". "Very well", then, said Viyunamali, Tarakaksha and Viryavana. "Grant us the following: Let three forts be made. The first will be of gold, the second of silver and the third of iron. We will live in these forts for a thousand years. These forts built in different worlds shall align once in every 1000 years. This combined fort will be called Tripura. And if anyone can then destroy Tripura with only a single arrow that shall be the death destined for us".
This rather unusual boon Brahma granted. There was a danava named Maya who was very good at building work. Brahma asked him to build the forts. The golden fort was built in heaven, the silver one in the sky and the iron one on earth. Tarakaksha got the golden fort, Viryavana the silver one and Vidyunmali the iron one. Each of the forts was a big as a city and had many palaces and vimanas (space vehicles) inside.
The demons populated the three forts and began to flourish. The demigods did not like this at all. They first went to Brahma, but Brahma said he could not help them. After all, the demons had got Tripura thanks to his boon. The gods then went to Shiva for help. But Shiva said that the demons were doing nothing wrong. As long as that was the case, he did not see why the demigods were so bothered. They next went to Vishnu, who suggested that if the problem was that the demons were doing nothing wrong, then the solution was to persuade them to become sinners.
Out of his powers Vishnu created a man. This man’s head was shaven, his clothes were faded and he carried a wooden water-pot in his hands. He covered his mouth with a piece of cloth and approached Vishnu. "What are my orders?" he asked Vishnu.
"Let me explain to you why you have been created", replied Vishnu. "I will teach you a religion that is completely against the Vedas. You will then get the impression that there is no svarga (heaven) and no naraka (hell) and that both heaven and hell are on earth. You will not believe that rewards and punishments for deeds committed on earth are meted out after death. Go to Tripura and teach the demons this religion, by which they will be ddislodged from the righteous path. Then we will do something about Tripura".
The being did as he had been asked to. He and four of his disciples went to a forest that was near Tripura and began to preach. They were trained by Vishnu himself. Therefore, their teachings were convincing and they had many converts. Even the sage Narada got confused and was converted. In fact, it was Narada who carried news of this wonderful new religion to king Vidyunmati. King, he said, there is a wonderful new teacher with a wonderful new religion. I have never heard before. I have got converted.
Since the great sage Narada had been converted. Vidyunmati also accepted the new religion, and in due course, so did Tarakaksha and Viryavana. The demons gave up revering the Vedas, they stopped worshipping Shiva’s linga.
Now the gods then went to Shiva and began to pray to him. When Shiva appeared, they told him that the demons had now become evil and should be destroyed. They had even stopped worshipping Shiva’s linga.
Shiva agreed to destroy Tripura. Vishvakarma was the architect of the gods. Shiva called Vishvakarma and asked him to make a suitable chariot, bow and arrow. The chariot was made entirely out of gold. Brahma himself became the charioteer and the chariot was speedly driven towards Tripura. The gods accompanied Shiva with diverse weapons.
When Shiva's army reached the battlefield, the three forts were about to merge into a single Tripura, which condition would last for just a second. At the exact time, Lord Shiva invoked the most destructive weapon controlled by Him, the Pashupatastra. The Destroyer's capable arms fired a single arrow into the three forts at the exact instant they merged into one, thus burning to ashes the three forts of the asuras. Shiva thus earned Himself the epithet Tripurantaka - the one who ended Tripura.
Another version that is widely quoted in Tamil literature has Lord Shiva destroy Tripura with a mere smile. When all the battlefield was filled with warriors, with Brahma and Vishnu in attendance, there occurred the instant when the forts came together. Lord Shiva merely smiled. The forts were burned to ashes. The battle was over before it began! In Tamil, Lord Shiva has the epithet, "Sirithu Purameritha Peruman" which means, He who burnt the cities with a mere smile.
While the celebrations were going on, the shaven-heads religious teachers arrived. "What are we supposed to do now?" they asked.
Brahma and Vishnu told them to go the desert where there are no humans. The last of the four eras was kaliyuga and in kaliyuga, evil would reign supreme. When kaliyuga arrived, they were to come back and begin their teaching afresh. And once they reached at their peak god will take rebirth and will wipe them from earth and once again the world will be free from all kinds of demons.