Abou Baseer reported: "I asked Imam Sadiq (Pbuh) about the cause of the adversity with which he was inflicted in Donia. The Imam (Pbuh) said: "It is because of a blessings that Allah granted him in Donia and he fulfilled the right of showing gratitude for it. At that time Iblees wasn’t prevented from reaching the throne as he was since the time he met Adam (pbuh). So when Iblees ascended and saw the gratitude of Ayyoub for the bounties bestowed upon him, he envied him. Iblees said: "O Lord, Ayyoub is only thanking You because of the bounties you gave him in Donia. If you prevent him from these bounties of Donia, he wouldn’t have thanked you ever. Give me power over his earthly life so that you know that he never fulfilled the right of showing gratitude for the bounties." It was said to him: "I granted you power over his money and children."
This happened because Allah wanted to show everyone the loyalty of Ayyoub (pbuh) and to make him a live model that makes the entire realms thank Allah for the bounties and be patient on adversities. This is why Allah allowed Iblees to have power over the earthly life of Ayyoub.
When Iblees took the permission from Allah he descended to earth and doomed all his money and children. Yet Ayyoub thanked and praised Allah more and more. Iblees said: "O Allah, grant me power over his sheep." Allah gave him power and so Iblees killed all his sheep. Yet Ayyoub thanked and praised Allah more and more. Iblees said: "Grant me power over his body." Allah granted him power over his body except his mind and eyes. Iblees breathed in him and so Ayyoub's body became full of ulcers. Ayyoub stayed for a long time like this but he kept thanking and praising Allah."