What does 한다 do here?
~아/어야 하다 (or 되다) = have to / must [verb]. In this case, it's 하다 which is conjugated in the plain form.
But why is this 한다 and not 하다?
Because 하다 is the dictionary form and you can't end a sentence in the dictionary form. The plain form conjugation, however, is valid. (Other conjugations are, of course, 해요, 합니다, 해, etc)
What's a fire engine again?
What starts with F and ends with UCK