Here's a breakdown of the events:
* Obito's Manipulation: Obito, under the influence of Madara Uchiha, wanted to trigger a war between the villages. He used his Sharingan to control Kurama and unleashed it upon the Leaf Village.
* The Fourth Hokage's Sacrifice: The Fourth Hokage, Minato Namikaze, confronted Kurama to protect his village. He successfully sealed the beast inside his newborn son, Naruto Uzumaki, sacrificing his own life in the process.
* The Consequences: The attack caused immense destruction and left a lasting scar on the Leaf Village. It also instilled a fear of jinchuriki (people who host tailed beasts) and led to Naruto being ostracized for a while.
In short: The Nine-Tailed Fox attack on the Leaf Village wasn't the result of the beast acting on its own. It was a deliberate act of violence orchestrated by Obito using the power of Kurama for his own manipulative ends.