What would happen if he wouldn’t? Like, what if the king were like, “I’m not really into the theatre. And actually, you know, I’ve got some business of State to get done tonight. You know, some king stuff. So you all enjoy the play.”
Would the play go on without him? Would Hamlet just cancel it? Would he reschedule it for a time he could make sure the king will see? What if the rest of Hamlet were Hamlet trying to get Claudius to come see his show? It would become a marketing drama, rather than a tragedy, perhaps. Maybe years would go by while Hamlet tries to get the King to watch this thing. He brings in critics to talk about how great it is. He has a bunch of postcards made and he leaves them everywhere the king happens to be. He stages pop-up teaser performances in the throne room.