Sheikh Fahd b. `Abd al-Rahmân al-Yahyâ, professor at al-Imâm University in al-Qasîm
The general ruling concerning insects and other small arthropods is that it is permissible to kill the harmful animals from among them. Evidence for this is that the Prophet (peace be upon him) said: “A prophet once sat under a tree when he got bitten by an ant so he burnt the ant’s village. Allah inspired to him: Why not only one ant?” [Sahîh Muslim]
Therefore, it was permissible to kill the harmful ant even though the general ruling is not to kill ants.
Abû Hurayrah said: “The Prophet forbade killing four animals; the ant, the bee, the hoopoe and the toad.” [Musnad Ahmad, Sunan Abî Dâwûd, and Sunan Ibn Mâjah] Ibn Kathîr said: “Its line of transmission is authentic.” (3/361).
As for those that are not harmful, the general ruling is for us not to kill them, since there is no reason for dong so. There is wisdom behind Allah's creating them, so it is not permissible to simply aggress against them for no good reason.
And Allah knows best.
Source: Islam Today