There are several aspects that play into account when it comes to "troubles," as you call it in your question.
First, the issue of qadar (pre-destination). In the famous Hadith Jibreel, the Messenger of Allah said (excerpt):
It is that you believe in Allah and His angels and His Books and His
Messengers and in the Last Day, and in fate (qadar), both in its good
and in its evil aspects. (Hadith Jibreel in Imam Nawawi's collection
of 40; from Saheeh Muslim)
This means that some of what happens to you was decided and written before your creation. This includes good things (like promotions) and bad things (like getting fired).
For the rest, Allah almighty says in the Qur'an:
Do the people think that they will be left to say, "We believe" and
they will not be tried? (Surah Ankabuwt, verse 2)
Whether you are a Muslim or not, Allah will test you in your life. Another verse even mentions:
And We will surely test you with something of fear and hunger and a
loss of wealth and lives and fruits, but give good tidings to the
patient. (Surah Baqarah, verse 155)
However, this does not account for everything. There is a strong concept in the Qur'an of "sin consequences" -- that people who sin suffer hard consequences of their actions in this life:
Corruption has appeared throughout the land and sea by [reason of]
what the hands of people have earned so He may let them taste part of
[the consequence of] what they have done that perhaps they will return
[to righteousness]. (Surah Room, verse 30)
Finally, it is impossible to live a life free of tests. Allah will always test you. One hadith says:
If Allah Loves a people, He tests them. (Tirmidhi)
The higher you go up in deen, the more Allah will test you; this is why the Prophets were tested the hardest. Some of them were even killed by their nations. They were outcast, ridiculed, and more.
So how, as Muslims, should we react to hardship? As the ayah in Surah Baqarah says (quoted above):
[...] but give good tidings to the patient: who, when disaster strikes
them, say, "Indeed we belong to Allah , and indeed to Him we will
return." (Surah Baqarah, verses 155-156)
The only cure is patience and good deeds. Allah says, one of the fruits of having eman is a good life:
Whoever does righteousness, whether male or female, while he is a
believer - We will surely cause him to live a good life, and We
will surely give them their reward [in the Hereafter] according to the
best of what they used to do. (Surah Nahl, verse 97)
And Allah knows best.