The purpose of "darkness" is to present man with a challenge - the challenge of strengthening his faith and uncovering God's presence. Because Joseph faced the trials of faith and stood up to them all, he merited the light of redemption.
The link between the feast of Joseph and his brothers in Egypt and the customary festive meal of Chanukah becomes clear. They together represent the attribute of trust in the Almighty.