Why is coff spelled cough?

Our spelling derives largely from Middle English, which is not that difficult to read. It would be much more difficult to understand if you were listening to it however, because those spellings reflect how the words were actually pronounced at that time. While the pronounciations have changed, the spellings have stayed the same.

That is to say, while we pronounce "knight" as "nite", Chaucer would have said "kin-nikhht". While you say "coff" he would say "cowkhh". While you say "ruff" he'd say "rowkhh" and so on.