The answer to this question is given in the Holy Quran in Surah Baqarah: ''But it is possible that you may dislike a thing which is good for you and you may love a thing which is which is bad for you, for Allah knows everything and you know not'' For example, if a very religious person, a very pious person he prays to Allah that please give me a motorcycle and his prayers is not answered, we will say what a religious person he is, why his prayers not being answered, Allah knows that if he acquires a motorcycle, he may have an accident and he may die as the Holy Quran says that you may love a thing which is bad for you, Allah knows you know not.

Once there was a very rich businessman who was going to catch a flight to London to click a deal which would fetch him a profit of 1 billion dollars and when he is traveling towards the airport, unfortunately, there is unusual traffic jam on road and he is unable to reach the airport on time, by the time he reaches the airport the flight has already taken off, he misses a flight and says ''THIS IS THE WORST THING EVER HAPPENED IN MY LIFE'' while going back to home he listens on radio that flight which he was supposed to catch, it Crashed and all the passengers on that flight they died so the businessman says '' THIS IS THE BEST THING EVER HAPPENED IN MY LIFE'' a few moments ago he was cursing the traffic jam, because of the traffic jam he lost billions of rupees and a few moments later on he thanks the traffic jam, it saved his life.

Allah says in Quran "you may dislike a thing which is good for you Allah knows you know not" Allah knows that the life of the businessman was more precious than billion of rupees he was about to earn, whatever you ask Allah (SWT) many a times he doesn't fulfill your prayers, he doesn't answer your prayers and its mentioned in the Holy Qur'an in Surah Shura "that if Allah wants to increase the provision of his servant they would surely transgress all bonds of the earth for Allah gives to them in due measures and He knows what he gives" its mentioned in the Quran that Allah says to his servants ask me and I will respond to your prayers, people may think that this verse isn't fulfilled if your prayers aren't answered actually if you analyse Allah (SWT) is answering your prayers by not answering it because He knows what is good and what is bad for you.

There are some who may say that we see many unbelievers many unpious people who worship the false god and they lead a very luxurious life, Allah (SWT) even if these unpious, unbelievers they pray to false god He fulfills their material desires because He knows what they are asking for is actually going them to cost more in a long run, in the hereafter, it cost nothing but lost. The true believers are those irrespective whether they are rich or poor, whether in good times or bad times, they yet believe in Allah as the Holy Quran says in Surah "Noor" That by the believers who neither traffic or merchandise can divert from remembering Allah (SWT) from establishing prayers, from giving regular charity, from humbling themselves, for these people only fear on that day on which hearts and eyes will be transformed they only fear the hereafter, the day of judgement, it is the final day of accounting, a true believers always say Alhumdulillah.