Since God can have foreknowledge without precluding or undermining our ability to choose freely, it is quite possible that He could teach Moshe, through prophecy, about future actions of certain individuals without necessarily robbing those individuals of their moral freedom. We see a precedent for this in the Covenant Between the Parts, where God tells Abraham that the Egyptians will enslave the Jews and eventually be punished. Thus, the idea that Moshe could have written of his own death, the mourning of the Israelites and their acceptance of Joshua is not surprising at all, and would in no way have interfered with the free choice of the Jewish people at that time.
Is not there a difference between God's foreknowledge and God informing Moshe about "the future actions of certain individuals"? Once God tells a prophet what a specific individual will do it is de facto the removal of that person's free will. All the future is before God but not all of the future can be revealed to prophets without removing man's free will. Rambam in Shemone P'rakim says that all predictions of future actions concern groups of people where no individual is singled out . Only in rare circumstances where God is actually removing a person's free will does God say what a specific individual will do (like Pharoa).
The answer to Yisrael (the person who asked the question Rabbi Maroof was responding to) then would be that the people following Joshua would be in the category of things that can be revealed to prophets without removing man's free will. Of course, after inspecting the pasuk more carefully:
וַיִּשְׁמְעוּ אֵלָיו בְּנֵי-יִשְׂרָאֵל וַיַּעֲשׂוּ, כַּאֲשֶׁר צִוָּה יְהוָה אֶת-מֹשֶׁה.
The pasuk does not say the people followed Joshua after Moshe's death it says they "paid heed to him and they did as God commanded Moshe." I can say with confidence that this is a very general prophecy and certainly would not violate any particular person's free will. Perhaps on another occasion I will explore what this pasuk means.