What is the proper salutation for a letter a king or queen?

Letters are usually sent to a monarch via their private secretary and should be addressed:

The Secretary to His (Her) Majesty King (Queen) Whomever

Address here

In Letter:

Your Majesty, or Sir, or Madam

If you are a subject, the proper formal valediction would be:

I have the honor to be, Sir (Madam), Your Majesty's humble and obedient servant,

Otherwise Sincerely or some other formal valedicition is is ok.