"I told you, months ago, that the Whomping Willow was planted the year I came to Hogwarts. The truth is that it was planted because I came to Hogwarts."
-- Remus Lupin (PA18)
The Whomping Willow is a very valuable, very violent tree planted alone in the middle of the school grounds. It was planted the same year that Lupin arrived at Hogwarts (c. 1971) to disguise the opening to a secret passage from Hogwarts to the Shrieking Shack. Lupin would go through a hole in the Willow’s roots every month and through a tunnel to transform into a werewolf in the Shack where he couldn’t hurt anyone. The Willow was so dangerous that it kept other people from entering the passage and encountering the werewolf.
No one was ever told what the Willow was really for. What people did know was that it would attack anyone who came within reach of its branches. Harry’s Nimbus 2000 broomstick sailed into the Willow and was smashed to bits (PA10). Harry and Ron accidentally crashed the flying Ford Anglia into it, and the tree severely dented and smashed the car before it could reverse out of range of the swinging branches (CS5).
Lupin told Harry that “(p)eople used to play a game, trying to get near enough to touch the trunk. In the end, a boy called Davey Gudgeon nearly lost an eye, and we were forbidden to go near it. No broomstick would have a chance.” (PA10). However, there is a way to temporarily paralyze the tree. There is a particular knot on the trunk which can be pressed using a long branch in order to stop the attacks (PA18). Sirius Black told Slytherin classmate Severus Snape how to stop the tree from whomping him, and somehow convinced him to do it on the night of a full moon. Snape was curious and it almost got him killed by Lupin transformed into a “fully-grown werewolf” at the end of the tunnel. James Potter managed to pull him out in time to save his life (PA14,PA18).
The Whomping Willow is injured when Harry and Ron crash Mr. Weasley's flying Ford Anglia into it at the beginning of their second year (CS5). Professor Sprout uses bandages to fashion slings for a number of the tree's branches (CS6).
The Whomping Willow's roots are used to conceal a room used by the remnants of Dumbledore's Army to fight the Ministry in the "Scorpion King" timeline created when Albus and Scorpius made a second trip back in time to try to repair the damage they'd caused on their first time travel escapade (CC3.5).
In the Prisoner of Azkaban movie, both Lupin and Snape use the Freezing Charm incantation "Immobilus" to halt the branches of the Whomping Willow.
One must wonder how Professor Sprout was able to put the Whomping Willow's branches in slings (CS6). Perhaps she is privy to the secret of how to freeze the tree. -BB
It seems likely that she would have been involved in the planting of the tree. We do know that other staff members knew of the true purpose of the Willow since Madam Pomfrey was responsible for bringing Lupin through the passage to the Shrieking Shack every month (PA18). --SVA