Dementors were written into the series as a representation of depression, a disease that J.K. Rowling has dealt with during her life.