Here are some reasons why this might have been done:
* Visual Spectacle: The scene provides a visually striking and dramatic moment for the film, showcasing the power and brutality of the Death Eaters and highlighting the danger Harry faces.
* Character Development: The scene gives Hermione a moment to shine by displaying her quick thinking and magical abilities, demonstrating her strength and resourcefulness in the face of danger.
* Emotional Impact: The attack creates a sense of urgency and peril for the characters, raising the stakes and leaving the audience on the edge of their seats.
* Plot Enhancement: The scene contributes to the overall narrative by highlighting the growing conflict between Harry and the Ministry of Magic, and the escalating danger faced by those who support him.
While the book focused on different aspects of the story, the film adaptation used this scene to enhance the visual and emotional impact of the narrative.