Here Allah tells us about His servant and Messenger Ayyub (Job) and how He tested him. These tests afflicted his body, his wealth and his children, until there was no part of his body that was healthy except his heart. Then he had nothing left in this world which he could use to help him deal with his sickness or the predicament he was in, besides his wife, who retained her devotion to him because of her faith in Allah and His Messenger. She used to work for people as a paid servant, and she fed and served him (Ayyub) for nearly eighteen years. Before that, he was very rich and had many children, being well off in worldly terms. All of that had been taken away until he ended up being thrown into the city dump where he stayed all this time, shunned by relatives and strangers alike, with the exception of his wife -- may Allah be pleased with her. She did not leave him, morning and evening, except for when she was serving people, then she would come straight back to him. When this had gone on for a long time, and things had gotten very bad, and the time allotted by divine decree had come to an end, Ayyub prayed to the Lord of the worlds, the God of the Messengers, and said:
The event relating to Sayyidna Ayyub (علیہ السلام) has been introduced here to comfort and prompt the Holy Prophet (علیہ السلام) ، so that he would also observe patience. This event has appeared with details in our commentary on Surah Al-Anbiya' (Ma’ ariful-Qur’ an, Volume V1). A few significant notes are being added here.
In the opening verse (41), it was said: مَسَّنِيَ الشَّيْطَانُ بِنُصْبٍ وَعَذَابٍ : (The Shaitan has inflicted weariness and pain upon me). Some early commentators have given details as to how the Shaitan had caused this affliction and pain. They say that the disease from which Sayyidna (علیہ السلام) suffered had overtaken him under the influence of the Shaitan. What happened was that once the angels praised Sayyidna Ayyub (علیہ السلام) in a manner that made the Shaitan envy him. He prayed to Allah Ta’ ala that he be given such control over his body, wealth and children that allowed him to do whatever he liked with him. Allah Ta’ ala too intended to test Sayyidna Ayyub (علیہ السلام) ، therefore, the Shaitan was given this right, and he made him suffer from this disease.
Every human being is liable to err. But, for the pious and righteous subjects of God, a wrongful act leads to great virtue, because after the misdeed, they turn towards their Lord with much more devotion and thus become entitled to a much better reward. On one occasion, Solomon made an error in judgement which required an interpretation and making a decision. When the truth dawned on him, he turned towards God with the utmost devotion. Almighty God forgave him and in addition gave him the reward of a great empire; He also gave him such extraordinary powers as no other man had ever enjoyed.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.