فبدأ بٲوعيتهم قبل وعاء أخيه
So he (Yusuf) began (the search) in their bags before the bag of his brother.
ثم استخرجها من وعاء أخيه
Then he brought it out of his brother's bag.
Therefore, Yusuf took Binyamin as a slave according to their judgement and the law which they believed in.
So Allah said;
كذلك كدنا ليوسف
Thus did We plan for Yusuf.
and this is a good plot that Allah likes and prefers, because it seeks a certain benefit using wisdom and the benefit of all.
Allah said next,
ما كان ليٲخذ أخاه في دين الملك
He could not take his brother by the law of the king,
as a captive, for this was not the law of king of Egypt, according to Ad-Dahhak and several other scholars.
Allah only allowed Yusuf to take his brother as a captive after his brothers agreed to this judgement beforehand, and he knew that this was their law.
إﻻ أن يشاء الله
except that Allah willed it.
This is why Allah praised him when He said,
نرفع درجات من نشاء
We raise to degrees whom We will,
just as He said in another Ayah,
يرفع الله الذين ءامنوا منكم
Allah will exalt in degree those of you who believe. (58:11)
Allah said next,
وفوق كل ذي علم عليم
but over all those endowed with knowledge is the All-Knowing.
Al-Hasan commented,
"There is no knowledgeable person, but there is another person with more knowledge until it ends at Allah the Exalted and Most Honored."
In addition, Abdur-Razzaq recorded that Sa`id bin Jubayr said, that we were with Ibn Abbas when he narrated an amazing Hadith.
A man in the audience said, `All praise is to Allah! There is an all-knowing above every person endowed with knowledge.'
Ibn Abbas responded, `Worse it is that which you said! Allah is the All-Knowing and His knowledge is above the knowledge of every knowledgeable person.'
Simak narrated that Ikrimah said that Ibn Abbas said about Allah's statement,
وفوق كل ذي علم عليم
(but over all those endowed with knowledge is the All-Knowing (Allah),
"This person has more knowledge than that person, and Allah is above all knowledgeable persons.''
Similar was narrated from Ikrimah.
Qatadah said,
"Over every person endowed with knowledge is a more knowledgeable person until all knowledge ends with Allah. Verily, knowledge started from Allah, and from Him the scholars learn, and to Him all knowledge returns.''
Abdullah bin Mas`ud read the Ayah this way,
(
وفوق كل عالم عليم
) "And above every scholar, is the All-Knower (Allah).''