How important are the grades compared to the cover letter when applying for a Ph.D?
When I look at an application there are four aspects that count:


grades
cover letter
earlier written work (BS/MS thesis)
Recommendation letters


Out of these, I focus most of my attention on the latter two: if the thesis is well-written, has received a good grade, and the letters of recommendation support the candidate in terms of ability to do research (from reading up on the field to writing everything up) and independence (how much (or little) support the candidate needed.

The cover letter would not make the application, but could break it if it is unfocussed and does not show any skills in expressing the interest in a structured way while avoiding irrelevant information. The grades would, in most cases, be the least interesting since they primarily show one's ability to read and understand, not necessarily reasoning and deduction. The exception is the grade for the thesis.

So, to answer the question, I am not sure which might be more important but anything that supports your ability to do research is of prime interest to anyone evaluating an application. 

EDIT: To follow up on Gerrit's suggestion, my personal ranking list would be (in falling order):


Earlier written work
Recommendation letters
Cover letter
Grades (although the grade on the written work is included in 1)


But, all parts are useful and in the end some mix of all will be used. I would also add that 1 and 2 will "make" the application while 3 and 4 will mainly help to "break" the application.