Why did the battle between the gods and the demons, led by Tarakasur, happen and how did it start?
As per Shiva Purana: RUDRA SAMHITA: PARVAT KHAND,
Why did the battle between the gods and the demons, led by Tarakasur happen?
Tarakasur wanted to rule the heaven.
Tarakasur demanded two boons - there should be no man as powerful as him and except Shiva's son nobody should be able to kill him. Lord Brahma blessed him by saying 'Tathastu'.
After receiving the boons, Tarakasur returned back to Ronitpur and was crowned as the king by Shukracharya. He then defeated the deities and drove them out from the heaven. Now it came under the rule of the demons.- English translation source
How did it start?
It started long back:
Narada was curious to know about Tarakasur. He asked Brahma to narrate his tale.
"Kashyapa-the son of Marichi, had thirteen wives Diti was the eldest among them. She was the mother of Hiranyakashipu and Hiranyaksha. Both her sons were killed by lord Vishnu in his incarnations of Nrisimha and Varaha respectively. Diti became very sad by the death of her sons.
After somtime she again became pregnant but the foetus was destroyed by Indra's weapon- Vajra in the womb itself. However Indra was not able to destroy the foetus completely, but was only successful in dividing the foetus into forty-nine parts. These forty-nine parts, later on became famous as 'Maraudganas'.
Again Diti gave birth of Vajrang, who was very valiant and brave. When he grew up, Diti ordered him to defeat the deities. With his mother's permission and blessings, Vajrang defeated the deities and held them captive. He fastened all the deities. With strings and himself became the king of heaven.
Seeing the pitable state of the deities I (Brahma) went to Vajrang accompanied by Kashyapa and requested him to free the deities. Vajrang agreed to free them but said he did not have any aspiration of becoming the king of heaven, he only wanted to teach a lesson to Indra.
Vajrang returned the heaven to the deities. Later on the married Varanji who had been created by me (Brahma). While Vajrang was of virtuous nature, Varangi was not."
Varangi gave birth to Tarakasur, the valiant and brave demon. During the time of his birth, the world was affected by inauspicious events like earthquakes, cyclones etc. His name Tarakasur was given by Kashyapa.
After he grew up, Tarakasur went to Madhuvan to do penance. His tremendous penance scarred the deities. Becoming pleased by his penance, lord Brahma appeared before him and asked him to demand anything. (See first part of Question which explains what Tarakasura demanded). - English translation source