The answer is dworked for a royal family (The Esterhazys).
This happen after Count Morzin suffered financial difficulties which forced Haydn out of job.
Not long after that, his talent was discovered by the wealthy Esterházy family and Haydn spent the majority of his career working for them.