Why write papers during the PhD?

You are testing your research prior to submitting your thesis.
Computer science supervisor from UCL, Clack says: ” 2-3 conference, or 1-2 journal papers in respectable (ACM, IEEE, IOP like) places are good enough for chapters 4,5,6 and therefore the core of a PhD – testing by publication is a VERY good defense (or defence).”

Your publishing record improves your chances of winning fee waivers and scholarships if you are in a university that offers them.

You are networking by submitting papers.
By publishing papers about your research in peer-reviewed and internationally-recognised journals you obtain external review and validation of your research. Reviewers start to recognise your name.

All sorts of people read the papers once published, not just academic researchers.
Publishing during the PhD results in established scholars or industry professionals seeing your work before you go onto the job market.