It's honestly really gross how the U.S. film industry works. There's a widely held belief that you basically have to have a white lead character in most films for it to be successful. Look at marvel, just as an example. Every single main character was a white man or woman. Iron Man, Captain America, Hulk, etc. All white people. Black Panther was the exception, not that he was even really part of the avengers officially. He wasn't really in their crew at their headquarters. But even the person who played vision, which was heavily dawdled in makeup... White person. That role could have been anyone! The dude looks like an alien, why did it have to be a white guy? Now look at Star Wars, another extremely popular franchise. Every single lead character is white without fail. Luke Skywalker, Anakin, the emperor, Leia, Han Solo, Kylo Ren, you name it, they are white. Mace Windu was the exception, and they just killed him off needlessly Like he was some inconsequential character even though he was literally the most important person in the entire Jedi order. Then Star Wars The Old Republic launched a video game and guess who is the leader of the Republic now? White woman.
Mace Windu getting killed was the turning point and point of no return for the three film character arc of Anakin Skywalker. That's a long way from "needlessly". Sure the character didn't have to be killed, but the impact of him being betrayed and killed was enormous. The plot of the third film (and the entire prequel trilogy) culminated with his death scene.