The king and duke were merely con-men pretending to be royalty. They met in Huck's raft because they were running away from the authorities who discovered their con.
They were initially strangers but upon knowing that each was a conman. Both hatched a plan to con numerous people by staging a play like Romeo and Juliet.