On one hand, I've learned that our destiny is fixed and does not change. On the other hand, I've learned a concept called "dua" which I use to talk to Allah, complaining and such. So would my "dua" change my destiny? If not, what's the use?
I learned that there are several different levels of qadr (or destiny). Side note: Delving into exactly how qadr works is not encouraged, probably because we don't know enough about how the ghaib works to begin dissecting it and expecting to understand how it works.
Back to the different levels thing - think of qadr at the lowest level as a sort of script for the universe. At a higher level, there could be instructions to change the script. Du'a is one of those instructions. According to the hadith, it is the only thing. Another hadith states that if anything were to overtake qadr, it would be the evil eye. At the highest level though, is the Lauh al-Mahfoodh, in which Allah SWT has preserved everything that will happen in this world, including the changing of qadr at the lower levels.
Imam ibn al-Qayyim says that du'a is a means - the same way we acquire the rizq that is written for us by working toward it, so do we make du'a as another means toward the same rizq.
Imam ibn Taymiyyah says similarly - qadr could be that Allah has commanded the angels to increase and decrease rizq based on actions. The hadith, for example, about increasing rizq by upholding familial relationships is a case in point. So du'a can change how we experience what was pre-written for us.
Allah is all knowledgeable i.e. he knows the present, the future to every fine detail. Dua doesn't change destiny. But, you do not know what is in store for you in your destiny. If you do dua, you will get the provision that has already been ordained for you. The fact that you will do dua is also known to the knowledge of Allah. But, you do not know the knowledge of Allah.
So, basically, we are encouraged to do dua to ask Allah things we need and also, dua is a form of worship. It has no overlap between destiny. It is just Allah's knowledge of what you will ask, what you will get, what you will say and what you will do. The fact that you asked this question is also already known to Allah.
Since, you do not know what is in store for you, you are encouraged to ask. You have a choice to ask or not to ask. Whatever the decision, it is already known to Allah. His knowledge doesn't prevent your free will.
For example, you might be jobless and searching for one badly. You do a lot of dua and you finally get it. You cannot say that you would have got it even if you didn't do dua, since it was fixed. No. The fact that you would do dua was known to Allah and also, that you would get this job. As simple as that.
And the Prophet salallahu alayhi wassalam forbade us from asking too much about Qadr.
And why worry about what is written?
I have borrowed the following excerpt from this answer:
you can ask Allah through a Dua, but when it is accepted you will see how the chain of events have been arranged such that what you wished was probable but even definite, so it seems even if you had not make Dua you still had it responded but that's not true, Allah who knew what you will ask an accepted Dua in the future has arranged the events from a long time before you Dua, and this is what makes the whole story ambiguity for some people, they don't find any position for Allah's will as they are shown a chain of causality.
Based on this explanation, Dua not only can change the future but even the past! Allah knows who will Dua at what time and which Dua will be accepted and how shoud be responded, so has arranged the whole causality chain in the way that the chain will guarantee the Dua being responded after it has been asked for! That the effect of Dua is perceived after it has been asked goes back to the fact that after asking Allah we will only meet the future at the proper times, not again the past that has passed! Therefore, you can even think of Dua itself as a cause in the chain of the causality and, thus, understand how a cause can affect both the past and the future, it is indeed more general than how commonly scientists think about the Causality.
Witnesses for thiw view can be found e.g. in the Hadeeth @Ezati has brought to you and many similar Ahadeeth. Also see:
هُوَ الَّذِي يُسَيِّرُكُمْ فِي الْبَرِّ وَالْبَحْرِ ۖ حَتَّىٰ إِذَا كُنتُمْ فِي الْفُلْكِ وَجَرَيْنَ بِهِم بِرِيحٍ طَيِّبَةٍ وَفَرِحُوا بِهَا جَاءَتْهَا رِيحٌ عَاصِفٌ وَجَاءَهُمُ الْمَوْجُ مِن كُلِّ مَكَانٍ وَظَنُّوا أَنَّهُمْ أُحِيطَ بِهِمْ ۙ دَعَوُا اللَّـهَ مُخْلِصِينَ لَهُ الدِّينَ لَئِنْ أَنجَيْتَنَا مِنْ هَـٰذِهِ لَنَكُونَنَّ مِنَ الشَّاكِرِينَ / فَلَمَّا أَنجَاهُمْ إِذَا هُمْ يَبْغُونَ فِي الْأَرْضِ بِغَيْرِ الْحَقِّ ...
He it is Who enableth you to traverse through land and sea; so that ye even board ships;- they sail with them with a favourable wind, and they rejoice thereat; then comes a stormy wind and the waves come to them from all sides, and they think they are being overwhelmed: they cry unto Allah, sincerely offering (their) duty unto Him saying, "If thou dost deliver us from this, we shall truly show our gratitude!" / But when he delivereth them, behold! they transgress insolently through the earth in defiance of right! ... [10:22,23]
in this verse Allah tells the story of some wrongdoers in a ship that they were seeing the signs of death coming to them from all around such that they could see no hope to outlast. So they only seek in refuge from Allah the omnipotent hopelessly but sincerely. Then Allah the omnipotent rescues them and deliver them to a land, and does this true the usual causes (like by ending the typhoon, blowing some favourable wind for them and etc), even this rescue might take some days during which they may also experience hunger and thirst and other difficulties but anyway Allah has survived them from death due to their Dua. When the rescued wrongdoers reach the land, some may recall they were definitely going to die and repent, but most will forget and ascribe to nature and ... a share in the gift they have received. This is what Allah has planned for Dunya, to leave each of us in a position that we should choose between what the intellect orders us and what the desire encourages us for in a sensible way. Therefore, Allah closes the verse [10:23] with
... يَا أَيُّهَا النَّاسُ إِنَّمَا بَغْيُكُمْ عَلَىٰ أَنفُسِكُم ۖ مَّتَاعَ الْحَيَاةِ الدُّنْيَا ۖ ثُمَّ إِلَيْنَا مَرْجِعُكُمْ فَنُنَبِّئُكُم بِمَا كُنتُمْ تَعْمَلُونَ
... O mankind! your insolence is against your own souls,- an enjoyment of the life of the present: in the end, to Us is your return, and We shall show you the truth of all that ye did.
Last but by no means least, mention that Dua changing the past and future, and the whole Causality thing is in the scale of us the creatures, whereas in the scale of Allah --the only true Cause-- what you have learned about that "our destiny is fixed and does not change" holds. See this question and the answers to it for better clarification of the situation. You should stop mixing the two viewpoints and there will be no contradiction left to be argued.
And Allah knows best
According to this hadith from Prophet Muhammad(SAWW), yes, dua can change our divine decree:
اِنَّ الرَّجُلَ لَيُحْرَمُ الرِّزْقَ بِالذَّنْبِ يُصِيْبُهُ؛ وَلا يَرُدُّ الْقَدَرَ اِلاّ الدُّعَاءُ وَلا يَزِيْدُ في الْعُمْرِ اِلاّ الْبِرُّ
Verily, committing sins deprives man of his sustenance; divine decree is not changed but through praying (dua) and long life is not gained but by kindness.
Yes, duas affect the future:
"And when My servants ask you, [O Muhammad], concerning Me—indeed I am near. I respond to the invocation of every supplicant when he calls upon Me..." (2:186)
Respond means to accept or deny (to give something better).
but they don't change qadr:
Ubadah ibn Al-Samit: Son! You will not get the taste of the reality of faith until you know that what has come to you could not miss you, and that what has missed you could not come to you. I heard the Messenger of Allah (ﷺ) say: The first thing Allah created was the pen. He said to it: Write. It asked: What should I write, my Lord? He said: Write what was decreed about everything till the Last Hour comes. Son! I heard the Messenger of Allah (ﷺ) say : He who dies on something other than this does not belong to me. (Sunan Abi Dawud)
If the Pen has already written down everything that is to happen it can't change, otherwise it would not have followed Allah's command correctly (as it wrote incorrectly).
It is a similar concept to how we have free will even though Allah knows everything that happens. Let me explain through an example:-
Allah writes the 'qadr' that you make a dua for a promotion, but you still make the dua from your own will. Allah just knows what you will choose to do, he doesn't necessarily control it.
Allah, in response to the dua (that he knows you make), will write in 'qadr' that you get a promotion.
So, the dua did affect your future but it didn't change Qadr. You chose to make a dua and the Pen had already written that into the Qadr, and Allah had already written the response to the dua too.
So, the choice you make to make a dua does make a difference, but it doesn't affect Qadr which Allah has already written down. If you had chosen to not make the dua, the dua would not have affected the future (as Allah would not have written it down).
Dua reverts both, what is written and what is not written. those whose qadr(fate) is made as childless may have a child because Allah has gifted us with such dua to make. forget about destiny. Keep asking whatever you want. Allah loves those who asks from Him and His greatness lies in giving. You can never be an Arab king by your dua. Your destiny is made where you are born. But definitely, you can lead the life of a king if you can make such dua.
Brothers & sisters. Almighty Allah (swt) knows best, & we cannot change our qadr. We can make dua to the almighty to help us & make our "destiny" better but only Allah (swt) knows best what is good for us. Once a dear brother told me when I posed such a similar question and he gave me a simple but effective answer, " if a kid asks for some sweets then a parent may give them a little but I'd the kid wanted more (lots more) then the grown up would know that the "sweet" isn't good for the teeth, & no matter how much the little one cries or rants around the grown up will eventually take control. When the kid grows older he/ she will realise that it was fir their benefit that their parent didn't give them too much sweets. Now, I hope that makes some sense. I may plead to the almighty Allah (set) about something but unless its fir my benefit I won't get it. This life is a mere test. Everything is controlled by the most high. Good or bad. Dua is a powerful tool which is asked solely from the almighty. If it can or cannot change destiny is a "massive" question but it says in the holy book (to the nearest meaning, Allah (swt) forgive me if I'm wrong, that; we should directly ask from Allah (swt).
Almighty Allah (swt) guide & protect us all (Ameen)