It is narrated from Sayyiduna Abdullah bin Mughaffal (may Allah be pleased with him) that the Noble Prophet (peace and blessings be upon him) ordered the killing of dogs, then said: "What concern do I have with dogs?" Then the Prophet (peace and blessings be upon him) permitted keeping dogs for farming and hunting.
(Commentary on Hadith 2044) The meaning of «مَابَالِىْوَلِلْكِلَابِ» is that keeping a dog is useless; rather, it is impure (najis), and there is a possibility that it may contaminate utensils or clothing. As for the matter of killing dogs, the command is only to kill the rabid, black, or biting dog, while dogs used for farming, livestock, hunting, and those that do not cause harm are excepted. And Allah knows best.