Why do graduate programs have comprehensive examinations (comps)?
The question is about exams taken at the end of a master's program. I have given such exams. In my mind, they make the candidate prove that they have mastered the material of the courses, which is a form of quality control. But the exams also have a few secondary goals in my mind:


By studying for the exams, students gain more understanding of the material, and come away better educated. The actual taking of the exam is less important, in a sense, than the time spent studying. If a student studies well, they should pass the exam. 
The exams keep the faculty honest when teaching, because the faculty know their students will have to pass exams that will be seen by other faculty. Exams within a course are often not seen by other faculty, so the instructor is not as publicly accountable. 
The exams help the faculty see what the students know, all in one setting. We can use this to revise courses at the departmental level if we find that many students have the same gaps in their knowledge.