The Knowledge of Allah, the Exalted, is unimaginable, vast, and unquestionably perfect. He knows what happened, what is going on, and what will happen about everything. Before the creation of anything He knows about it and its final destination. Allah, the Exalted, says:
(Undoubtedly, We created everything according to an estimate)
[Holy Quran, Chapter: 54, Verse: 49 ]

Giving more detail about the destiny of the creations, the Prophet (Peace be upon him) said, “Allah, the Exalted, has written down the destinies of the creations before the creation of heavens and earth; around fifty thousand years ago.”
[Muslim: Imam Muslim, Vol: 7, Page: 275 ]

Writing of destinies for us does not mean that we are forced to do according to what has been written down by Allah, the Exalted. In fact, it is Allah, who knew through His matchless knowledge about what we will do after our creations. So, on the basis of His knowledge, he had written our doings earlier.
Therefore, one whose last destination is Paradise, he will have his way to get in, and it will be made possible through his guidance to righteous deeds. Likewise for a person whose fate is to get in Hell will act wrongfully. As the Prophet Muhammad (Peace be upon him) said, “There is not anyone amongst you for whom a seat in paradise or Hell has not been assigned and about whom it has not been written down whether he would be miserable person or a happy one. A man asked, “O Prophet of Allah; should we not then depend upon our destiny and abandon our deeds?” Thereupon, he replied, “Do try because, whoever belongs to a company of happiness; he will have good works made easier for him, and who belongs to the company of misery; he will have evil acts made easier for him….”
[Muslim: Imam Muslim, Vol: 7, P: 264]

The way of writing destiny for an individual was described in detail by the Prophet (Peace be upon him) as he informed us saying, “…An angel is being sent to the fetus of a mother by Allah, the Exalted so, he asks, “O Lord! Prosperous or not-prosperous? And that would be written down. Then he asks, male or female? Then this would be recorded. Then, his deeds, provisions, age, and means of life would be recorded.”
[Muslim: Imam Muslim, Vol: 7, P: 261]

According to the Prophet Muhammad (Peace be upon him), one’s place of death was decided earlier too. For that place, one would be taken before his death as Allah, the Almighty, will cause him to go there for a reason.
[See, Tirmizi; Imam Muhammad Bin Isa Tirmizi, Vol: 1,Page: 795]

Talking about this topic, one may think that why he should not give up his all efforts to ease the burdens of his life depending solely on his destiny? Interestingly, the same question was asked to the Prophet Muhammad (Peace be upon him). A person asked, “What do you say about a certain Dua that we read, a medicine that we take, and means of safety that we use. Do these change the destiny set by Allah, the Exalted?” He replied, “These means are also part of the Destiny. ”
[See, Tirmizi: Imam Muhammad Bin Isa Tirmizi, Vol: 1, page: 796]

In fact, Qaza is of three kinds; Qaza-e-Mubram (Unchangeable decision), Qaza-e-Mullaq (Hanging Decision) and, Qaza-e-Mullaq Shabeeh Ba Mubram (Hanging Decision that is like unchangeable Decision)
Unchangeable Decision: This type of Qaza decided by Allah, the Exalted, it can not be changed at all.
Hanging Decision: This type of Qaza is like being hanged on something, such as using medicines, making Dua, giving charity, or etc. Also, this is clearly explained in the register of Angels. As for example, “This was decided for him but he will make Dua and then it would be changed in such a way..
Hanging Decision like unchanged: This is a Qaza that was changeable in the knowledge of Allah, the Exalted, but was written as unchangeable in the register of Angels. Those decisions may be changed through Dua as the Prophet Muhammad (Peace be upon him) informed us.
[See, Anwaarul Hadith: Mufti Jalaluddin Ahmed Amjadi, Page: 120-121]