Cover letter for a publication
The practice of cover letters predates the now common online submission systems by centuries: Before online submission, papers were submitted by sending a hard copy via postal mail to the editor-in-chief (in person, not via a journal). Now it's mostly a formality, but since scholars are a traditional bunch, old habits die hard. 
(EDIT: Even so, if the journal demands a cover letter, you must provide one, or risk having your submission rejected for not following the guidelines.)

In principle, any information contained in a cover letter should also be put somewhere into the submission form, so those can be of some guidance. Things usually appearing in the letter include


the title of the work;
the type of manuscript (if the journal not only publishes standard papers but also short notes, literature review etc.);
the name of the journal you are submitting to (since the editor might manage several journals);
a brief summary (one or two sentences) to give the editor some idea
whether the manuscript is within the scope, and which associate
editor to forward it to;
a clear statement that the manuscript has not been submitted elsewhere;
the full contact details of the corresponding author (presumably the one signing the cover letter);
a list of preferred or excluded referees and/or associate editors, if applicable.


Here's what I usually write (addressed to the editor-in-chief at his department address):


  Dear Professor X,
  
  please find attached our manuscript "A Note on Piffles", which we
  would like to submit for publication as an original research article
  in your journal Wuffle Review. Our main result is that all universal
  Piffles are strictly ascending, which proves a conjecture of Smith et
  al. This work has not been submitted elsewhere.
  
  The corresponding author is
  
  [...]
  
  We are looking forward to hearing from you.
  
  Sincerely, 
  
  Y