All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad is His slave and Messenger.
Allah the Almighty says in Surah An-Nisaa' (what means): {What comes to you of good is from Allah, but what comes to you of evil, [O man], is from yourself. And We have sent you, [O Muḥammad], to the people as a messenger, and sufficient is Allah as Witness.} [Qur'an 4: 79], and its meaning is as the commentators said: {What comes to you of good...} i.e., a favor or a blessing {is from Allah}, and He is the One who bestows and provides it. {But what comes to you of evil} i.e., an affliction or a matter that you hate, {is from yourself}, that is: because of your sins and what you have earned, but what He (Allah the Almighty) pardons is much more.
Ibn Katheer said in his interpretation: {What comes to you of good is from Allah} means from Allah’s grace, kindness, and mercy. {But what comes to you of evil is from yourself} means from your own work, as Allah the Almighty says (what means): {And whatever strikes you of disaster - it is for what your hands have earned, but He pardons much.} [Quran 42: 30].
As-Suddi, Al-Hasan Al-Basri, Ibn Jurayj, and Ibn Zaid said: {... is from yourself}, meaning: because of for your sin.
Qataadah said concerning this verse, “is from yourself” means, as a punishment to you, O son of Adam, for your sin. He said: It was mentioned to us that the Prophet used to say: “No man is scratched by a thorn, or stumbles, or has a twitching in a vein, except for a sin, and what Allah forgives is greater.”
Allah knows best.