Was Bani-Israel's Destiny Already Written?
Bani-Israel were punished for their rebellion, not because of God’s knowledge or their destiny. The same way we humans will be punished for our actions on the day of judgement, depsite the fact God’s knowledge encompasses everything. They were warned of this quite vehemently by Prophet Moses (sws) before he passed away, still they rebelled against God. See Deuteronomy 31:15-29 under heading “ Israel’s Rebellion Predicted “.