In the anime, the nine tails were summoned by Madara/Tobi during Naruto's birth and made to attack Konoha. Later Minato saved the village. For what reason the nine tails was made to attack Konoha?
Madara/Tobi had taken control of the Nine-Tails, but during his battle with Minato, Minato removed the Nine-Tails from the control of Tobi. Then Tobi escapes from the battle.
This is where the Nine-Tails was summoned by Madara/Tobi in Konoha (chapter 502):
This is when Minato removes the Nine-Tails from the control of Madara/Tobi (chapter 503):
This is when Madara/Tobi escapes:
Now, since no one was present to control the Nine-Tails, he went on a rampage and thus attacked the village.
Initially, Madara/Tobi wanted to keep control of the Nine-Tails and use its power for himself, and destroy Konoha. But now the Nine-Tails was a loose canon destroying Konoha on its own free will.
After Rin, who was someone very special to Obito, was killed, he was taken by hatred towards the Ninja world. Uchiha Madara had for long contained hatred for the Senju clan. After his defeat in the hands of the First Hokage - Hashirama Senju, had made the destruction of Konoha his vendetta. Madara saped into this hatred of Obito and toned Obito's thoughts to suit his own needs. When Madara/Tobi learned that Kushina is about to deliver a child, they made their move, as the time of delivering the child is when the seal is the weakest for a Jinchuruki. Having a Tailed Beast in his disposal would have been a great advantage for Madara, as he was already planning something that concerned the Bijuus.
Thus Madara/Tobi attacks Konoha, and in turn the Nine-Tails attacks Konoha.
The question here is not the actual reason of the Nine Tails attack to Konoha, but the actual reason of the Masked Man attack to Konoha.
The attack of the Nine-Tailed Demon Fox, coincided with Kushina Uzumaki, the Nine-Tails' second jinchūriki, giving birth to Naruto on the night of October 10th. During a female jinchūriki's pregnancy, the energy used to maintain the seal has to be redirected to the growing child in her womb — whether consciously done or not. As a result, the seal used on the beast weakens in direct proportion, and as such special preparations have to be made when a female jinchūriki is about to give birth as the seal may break entirely (Naruto Episode 500 Pages 8-9).
However, the childbirth's location was eventually discovered by Tobi, who learned the information by observing Kakashi at the Konoha Cemetery.
Making his way to the site, Tobi killed the ANBU stationed outside and later Biwako and Taji after the child had been born(Naruto Episode 500 Pages 13-17).
Holding the newborn Naruto at ransom, he forces Minato to leave the cave via his Flying Thunder God Technique when he sets off the explosive tags he had placed on the newborn's blanket.
Taking advantage of Minato's absence, Tobi forcibly extracted the Nine-Tails from a visibly exhausted Kushina while noting that the Four Symbols Seal also carried the Flying Thunder God Technique seal as a security measure which would enable Minato to teleport to his wife's aid at any time(Naruto Episode 501 Pages 1-6).
As the Nine-Tails finally emerged from the seal, Tobi used his Sharingan to gain control of the tailed beast and commands it to destroy Konoha.
The main reason however is notably clear. Tobi/Madara took advantage of the weakened seal because of Kushina's child birth and to take control over the Kyuubi. The attack to Konoha is just a secondary effect from Tobi taking control of the Kyuubi. The attack was merely a prerequisite of his main plan of collecting the Kyuubi. We knew that the Eye of the Moon Plan requires all the tailed beast in order to form the Bijuu; and the very root of these plan is to fill the empty hole in the heart of Obito(Naruto Episode 530 "What can fill the hole" Pages 4-5).