How can you write a request letter for refund of earnest money?

You could look up a store that sells legal documents and simply fill in the blanks. This way all the legal work is done for you.