The subject matter of this Surah indicates that it was revealed during the last stage of the Holy Prophet's residence at Makkah, when the Quraish were considering the question of killing or exiling or imprisoning him. At that time some of the unbelievers put this question (probably at the instigation of the Jews) to test him :"Why did the Israelites go to Egypt?" This question was asked because they knew that their story was not known to the Arabs for there was no mention of it whatever in their traditions and the Holy Prophet had never even referred to it before. Therefore they expected that he would not be able to give any satisfactory answer to this question or would first evade it, and afterwards try to inquire about it from some Jew, and thus he would be totally exposed. But, contrary to their expectations, the tables were turned on them, for Allah revealed the whole story of Prophet Joseph then and there, and the Holy Prophet recited it on the spot. This put the Quraish in a very awkward position because it not only foiled their scheme but also administered a warning to them by aptly applying it to their case, as if to say, "As you are behaving towards this Prophet, exactly in the same way the brothers of Prophet Joseph behaved towards him; so you shall meet with the same end."
From the above it is clear that this Surah was sent down for two objects:
The first object was to give the proof of the Prophethood of Muhammad (Allah's peace be upon him), and that too, the one demanded by the opponents themselves so as to prove conclusively that his knowledge was not based on mere hearsay, but was gained through Revelation. This aspect has been stated explicitly in its introductory verses and explained plainly in its concluding portion.
The second object was to apply it to the Quraish and warn them that ultimately the conflict between them and the Holy Prophet would end in his victory over them. As they were then persecuting their brother, the Holy Prophet, in the same way the brothers of Prophet Joseph had treated him. The Quraish were told indirectly that they would also fail in their evil designs just as the brothers of Prophet Joseph had failed in his case, even after casting him into the well. This is because none has the power to defeat the Divine will. And just as the brothers of Prophet Joseph had to humble themselves before him, so one day the Quraish shall have to beg forgiveness from their brother whom they were then trying to crush down. This, too, has been made quite plain in v. 7: "Indeed there are signs in this story of Joseph and his brothers for these inquirers from among the Quraish."
The fact is that by applying this story to the conflict, the Quran had made a bold and clear prophecy, which was fulfilled literally by the events that happened in the succeeding ten years. Hardly two years had passed after its revelation, when the Quraish conspired to kill the Holy Prophet like the brothers of Prophet Joseph, and he had to emigrate from Makkah to Al-Madinah, where he gained the same kind of power as Prophet Joseph had gained in Egypt. Again, in the end the Quraish had to humble themselves before him just like the brothers of Prophet Joseph, when they humbly requested, "Show mercy to us for Allah rewards richly those who show mercy" (V. 88), and Prophet Joseph generously forgave them, (though he had complete power to wreak vengeance on them,) saying, " today no penalty shall be inflicted on you. May Allah forgive you:He is the greatest of all those who forgive" (V. 92). The same story of mercy was repeated, when after the conquest of Makkah, the crest fallen Quraish stood meekly before the Holy Prophet, who had full power to wreak his vengeance on them for each and every cruelty committed by them. But instead, he merely asked them, "What treatment do you expect from me now?" They replied, "You are a generous brother and the son of a generous brother." At this, he very generously forgave them, saying, "I will give the same answer to your request that Joseph gave to his brothers: “...today, no penalty shall be inflicted on you: you are forgiven."
Moreover, the Quran does not relate this story as a mere narrative but uses it, as usual, for the propagation of the Message in the following ways:-
Throughout the narrative the Quran has made it clear that the Faith of Prophets Abraham, Isaac, Jacob and Joseph (Allah's peace be upon them all) was the same as that of Prophet Muhammad (Allah's peace be upon him) and they invited the people to the same Message to which Muhammad (Allah's peace be upon him) was inviting them.
Then it places the characters of Prophet Jacob and Prophet Joseph side by side with the characters of the brothers of Joseph, the members of the trade caravan, the court dignitary; Al Aziz of Egypt and his wife, the "ladies" of Egypt and the rulers of Egypt and poses a silent question to the reader, as if to say, "Contrast the former characters molded by Islam on the bedrock of the worship of Allah and accountability in the Hereafter with the latter molded by kufr and "ignorance" on the worship of the world and disregard of Allah and the Hereafter, and decide for yourselves which of these two patterns you would choose."
The Quran has used this story to bring forth another truth: whatever Allah wills, He fulfills it anyhow, and man can never defeat His plan with his counterplans nor prevent it from happening nor change it in any way whatever. Nay, it often so happens that man adopts some measure to fulfill his own design and believes that he has done that very thing which would fulfill his design, but in the end he finds to his dismay that he had done something which was against his own and conducive to the Divine purpose. When the brothers of Prophet Joseph cast him into the well, they believed that they had once for all got rid of the obstacle in their way but in fact, they had paved the way for the Divine purpose of making him the ruler of Egypt, before whom they would have to humble themselves in the end. Likewise, the wife of Aziz had sent Prophet Joseph to the prison, floating over the thought that she had wreaked her vengeance on him, but, in fact, she had provided for him the opportunity for becoming the ruler of Egypt and for putting herself to the shame of confessing her own sin publicly.
And these are not the solitary instances which prove the truth that even if the whole world united to bring about the down fall of the one whom Allah willed to raise high, it could not succeed. Nay, the very "sure and effective" measures that were adopted by the brothers to degrade Joseph were used by Allah for the success of Joseph and for the humiliation and disgrace of his brothers. On the other hand, if Allah willed the fall of one, no measure, howsoever effective, could raise him high : nay, it helped to bring about his fall and the disgrace of those who adopted them.
Moreover, the story contains other lessons for those who intend to follow the way of Allah. The first lesson it teaches is that one should remain within the limits, prescribed by the Divine Law, in one's aims and objects and measures, for success and failure are entirely in the hands of Allah. Therefore if one adopts pure aims and lawful measures but fails, at least one will escape ignominy and disgrace. On the other hand, the one who adopts an impure aim and unlawful measures to achieve it, shall not only inevitably meet with ignominy and disgrace in the Hereafter, but also runs the risk of ignominy and disgrace in this world.
The second lesson it teaches is that those who exert for the cause of truth and righteousness and put their trust in Allah and entrust all their affairs to Him, get consolation and comfort from Him, for this helps them face their opponents with confidence and courage and they do not lose heart, when they encounter the apparently terrifying measures of the powerful enemies. They will persevere in their task without fear and leave the results to Allah.
But the greatest lesson this story teaches is that if the Believer possesses true Islamic character and is endowed with wisdom, he can conquer a whole country with the strength of his character alone. The marvelous example of Prophet Joseph teaches us that a man of high and pure character comes out successful even under the most adverse circumstances. When Prophet Joseph went to Egypt, he was only a lad of seventeen years, a foreigner, all alone and without any provisions; nay, he had been sold there as a slave. And the horrible condition of the slaves during that period is known to every student of history. Then he was charged with a heinous moral Crime and sent to prison for an indefinite term. But throughout this period of affliction, he evinced the highest moral qualities which raised him to the highest rank in the country.
The following historical and geographical details will help understand the story:
Prophet Joseph was a son of Prophet Jacob and a grandson of Prophet Isaac and a great grandson of Prophet Abraham (Allah's peace be upon them all). The Bible says (and the allusions in the Quran also confirm this) that Prophet Jacob had twelve sons from four wives. Prophet Joseph and his younger brother Benjamin were from one wife and the other ten from the other wives. Prophet Jacob had settled at Hebron (Palestine) where his father Prophet Isaac and before him Prophet Abraham lived and owned a piece of land at Shechem as well.
According to the research scholars of the Bible, Prophet Joseph was born in or about 906 B. C. and the incident with which this story begins happened in or about 890 B. C. He was seventeen when he saw the dream and was thrown into the well. This well was near Dothan to the north of Shechem according to Biblical and Talmudic traditions, and the caravan, which took him out of the well, was coming from Gilead (Trans-Jordan), and was on its way to Egypt.
At that time Fifteenth Dynasty ruled over Egypt, whose rulers are known in history as the Hyksos kings. They belonged to the Arab race, but had migrated from Palestine and Syria to Egypt in or about 2000 B. C. and taken possession of the country. The Arab historians and the commentators of the Quran have given them the name of Amaliq (the Amalekites), and this has been corroborated by the recent researches made by the Egyptologists. They were foreign invaders who had got the opportunity of establishing their kingdom because of the internal feuds in the country. That is why there was no prejudice in the way of Prophet Joseph's ascendancy to power and in the subsequent settlement of the Children of Israel in the most fertile region of Egypt. They could gain that power and influence which they did, because they belonged to the same race as the foreign rulers of Egypt.
The Hyksos ruled over Egypt up to the end of the fifteenth century B. C., and practically all the powers remained in the hands of the Israelites. The Quran has made a reference to this in v. 20 of Al-Ma'idah: “...He raised Prophets among you and made you rulers.” Then there arose a great nationalist movement which overthrew the power of this dynasty and exiled 250,000 or so of the Amalekites. As a result of this, a very bigoted dynasty of Copts came into power and uprooted everything connected with the Amalekites. Then started that persecution of the Israelites which has been mentioned in connection with the story of Prophet Moses.
We also learn from the history of Egypt that the "Hyksos kings" did not acknowledge the gods of Egypt and, therefore, had imported their own gods from Syria, with a view to spreading their own religion in Egypt. This is the reason why the Quran has not called the king who was the contemporary of Prophet Joseph by the title of "Pharaoh," because this title was associated with the religion of the original people of Egypt and the Hyksos did not believe in it, but the Bible erroneously calls him "Pharaoh." It appears that the editors of the Bible had the misunderstanding that all the kings of Egypt were "Pharaohs."
The modern research scholars who have made a comparative study of the Bible and the Egyptian history are generally of the opinion that Apophis was the Hyksos king, who was the contemporary of Prophet Joseph.
At that time Memphis was the capital of Egypt, whose ruins are still found on the Nile at a distance of 4 miles south of Cairo. When Prophet Joseph was taken there, he was 17 or 18 years old. He remained in the house of Aziz for three years and spent nine years in prison, and then became the ruler of the land at the age of thirty and ruled over Egypt independently for eighty years. In the ninth or tenth year of his rule he sent for his father, Prophet Jacob, to come from Palestine to Egypt with all the members of his family and, according to the Bible, settled them in the land of Goshen, where they lived up to the time of Prophet Moses. The Bible says that before his death, Prophet Joseph bound his kindred by an oath: "when you return from this country to the house of your forefathers you must take my bones out of this country with you. So he died a hundred and ten years old, and they embalmed him..."
Though the story of Prophet Joseph as given in the Quran differs very much in its details from that given in the Bible and the Talmud, the Three generally agree in regard to its component parts. We shall explain the differences, when and where necessary, in our Explanatory Notes.
Source: Sayyid Abul Ala Maududi - Tafhim al-Qur'an - The Meaning of the Quran