The Keli Yakar gives an interesting explanation as to why Yosef demanded that all Egyptians be circumcised, before he distributed food.
He uses a kind of Aggadic גזירה שוה, comparing the use of the same word in two different situations. The word in question is חרפה, which is a strong word for “shame.”
The brothers told that the people of Shechem that it would be a חרפה, a shameful act, to allow their sister to marry someone with a foreskin. This was certainly true when David faced Goliath. He referred to Goliath as the “uncircumcised Philistine.”
The word “חרפה” was used again in the Book of Yechezkel, when he predicted the future where Jews would no longer suffer from חרפת הרעב, “the shamefulness of famine.”
Yosef, in his great wisdom connected the two ideas of חרפה. He concluded that the avoidance of the humiliation of famine, can be alleviated by performing circumcision.
This was the reason, according to the Keli Yakar for Yosef’s demand that all Egyptians be circumcised.