Why Did the Nine-Tailed Fox Attack the Leaf Village?

The Nine-Tailed Fox, Kurama, did not attack the Leaf Village on its own. It was controlled by the villain Obito Uchiha, who used it as a weapon.

Obito, influenced by Madara Uchiha, used his Sharingan to control Kurama and unleash it on the village. The Fourth Hokage, Minato Namikaze, confronted Kurama and sealed the beast inside his newborn son, Naruto, sacrificing his life.

The attack caused massive destruction, left a lasting scar on the village, and led to Naruto being ostracized for a time.