"[That He might test you] means: to put you to the test through commands and prohibitions. [As to which of you is best in deed] means: regarding that which He has tested you with of commands and prohibitions.
Muhammad said: The meaning is: He tests you with the testing for which He will recompense you; yet He already knew before that which of them would be best in deed.
Surah Hud from verse (8) to verse (12)."