Grievous is just a villain, and Obi-wan fights him. It’s stupid but there it is, it exists for that reason. C3PO and the factory is ??? who even knows.
It wasn’t in the script. The Indulgent One came up with the scene on set and just thought it would be cool to put in the movie.