It's a play. There are lots and lots of plays that feature real people as characters, with dialogue scripted by the writer, many of them not based on real life events and many of them controversial or portraying them in a bad light. King Charles III (written long before he was king) was an extremely popular West End play that reimagined the future of the royals and wasn't based on fact. Dear England (featuring a fictional version of Gareth Southgate) is the biggest hit play around. And of course there have been lots of TV shows, like the Crown and the Windsors, that use the royals as fictional versions of real people. The same person who wrote Dear England also wrote the Brexit movie which fictionalised Boris Johnson and others.
It's not illegal to put a fictional version of a real person on stage, and the law can't discriminate based on whether that portrayal matches our own politics or not. Either it's legal to represent real people on stage or it's not. If it's not, that means no one can ever write a play or movie or TV show about any political or historical figure, or about royalty. Or any movie based on real life events. You can't say "King Charles III is fine but not this play, because that play matched my opinions and this one doesn't."
If you want a blanket law banning all TV shows, movies, and stage plays about real people then fine, but you can't go "well the Crown is fine, or that movie about Margaret Thatcher was fine, but not this."