excellent question my friend;
for believers of the one God and are muslims:
1) can be punishment for who are doing very big sins (Kabaer) such as drinking, adultary, leaving prayers or other, this can be a warning to make them come back
32:21 (Asad) However, ere [We condemn them to] that supreme suffering, We shall most certainly let them taste of a suffering closer at hand, [16] so that they might [repent and] mend their ways. [17]
2) can be warning signs for those with lots of sins but not all very big so they can be warned and recommitted
68:17 (Asad) [As for such sinners,] behold, We [but] try them [11] as We tried the owners of a certain garden who vowed that they would surely harvest its fruit on the morrow,
68:18 (Asad) and made no allowance [for the will of God]:
68:19 (Asad) whereupon a visitation for thy Sustainer came upon that [garden] while they were asleep
68:20 (Asad) so that by the morrow it became barren and bleak
3) for good believers can be for raising their level in heavens or cleansing their sins as God knows they will be patient on this suffering
2:155 (Asad) And most certainly shall We try you by means [125] of danger, and hunger, and loss of worldly goods, of lives and of [labour's] fruits. But give glad tidings unto those who are patient in adversity
فعن أنس بن مالك ـ عن رسول الله صلى الله عليه وسلم أنه قال: عِظم الجزاء، مع عظم البلاء، وإن الله إذا أحب قوماً ابتلاهم، فمن رضي فله الرضا، ومن سخط فله السخط