The demon Taraka was killed by Kartikeya, the son of Lord Siva. His 3 sons Tarakaksha, Vidyunmali and Kamalaksha were furious and wanted to take revenge. They worshiped Brahma and asked for a boon of immortality. Brahma said he cannot grant that. They came up with a clever idea. They asked from Brahma for 3 cities which will float in the heavens, the skies and the earth plane respectively. These cities can only be destroyed when all 3 are aligned in straight line and can be destroyed only by a single arrow and that too shot by none other than lord Siva himself. Brahma granted them their wish. So gaining virtual immortality, the 3 demon brothers started creating havoc. Gods pleaded to Siva and Siva agreed to help. Vishwakarma, the celestial architect designed the heavenly chariot. Sun became the right wheel and Moon the left wheel, Vishnu entered the arrow of Siva and Brahma was the charioteer. Siva went on the chariot and at the exact time when 3 cities were aligned when Pushya Nakshatra was rising on the horizon and at the Muhurata of Abhijit, Siva shot the arrow and destroyed the 3 cities.
From that point on, Siva received the name Tripurantaka, the slayer of the 3 cities.
Siva is the divine archer. He is the spirit. Three cities represent the three gunas – sattva, rajas and tamas. All three gunas have to come to a state of equilibrium (in a straight line) before the divine archer (Siva) can shoot the arrow of wisdom (Vishnu) and kill (harmonize) all three cities (gunas) and thus give redemption to the jivatma or embodied soul. The time has to be ripe for such liberation, so the arrow has to be shot at the right moment / Muhurata.