I think it is confusing, because I don't know if you mean, "as many as the king desired to participate" or "anyone who desired to participate." ( who is doing the "desiring", the king or the people invited?)
I think you mean the latter, so I would write, "... The king decided to have a contest. He invited all his subjects to compete to see who could travel the highway the fastest."
("Subjects" here meaning "the members of his kingdom.")
If you mean the first and the king is the one desiring, "... a contest. He invited a select number of his subjects to compete ..." Or "... he invited those whom he desired to participate to compete ...".