1 When Jacob saw that there was grain in Egypt, Jacob said to his sons, “Why do you look at one another?”
2 And he said, “Indeed I have heard that there is grain in Egypt; go down to that place and buy for us there, that we may live and not die.”
3 So Joseph’s ten brothers went down to buy grain in Egypt.
4 But Jacob did not send Joseph’s brother Benjamin with his brothers, for he said, “Lest some calamity befall him.”
5 And the sons of Israel went to buy grain among those who journeyed, for the famine was in the land of Canaan.
6 Now Joseph was governor over the land; and it was he who sold to all the people of the land. And Joseph’s brothers came and bowed down before him with their faces to the earth.
7 Joseph saw his brothers and recognized them, but he acted as a stranger to them and spoke roughly to them. Then he said to them, “Where do you come from?” And they said, “From the land of Canaan to buy food.”
8 So Joseph recognized his brothers, but they did not recognize him.
9 Then Joseph remembered the dreams which he had dreamed about them, and said to them, “You are spies! You have come to see the nakedness of the land!”
10 And they said to him, “No, my lord, but your servants have come to buy food.
11 We are all one man’s sons; we are honest men; your servants are not spies.”
12 But he said to them, “No, but you have come to see the nakedness of the land.”
13 And they said, “Your servants are twelve brothers, the sons of one man in the land of Canaan; and in fact, the youngest is with our father today, and one is no more.”
14 But Joseph said to them, “It is as I spoke to you, saying, ‘You are spies!’
15 In this manner you shall be tested: By the life of Pharaoh, you shall not leave this place unless your youngest brother comes here.
16 Send one of you, and let him bring your brother; and you shall be kept in prison, that your words may be tested to see whether there is any truth in you; or else, by the life of Pharaoh, surely you are spies!”
17 So he put them all together in prison three days.
18 Then Joseph said to them the third day, “Do this and live, for I fear God:
19 If you are honest men, let one of your brothers be confined to your prison house; but you, go and carry grain for the famine of your houses.
20 And bring your youngest brother to me; so your words will be verified, and you shall not die.” And they did so.
21 Then they said to one another, “We are truly guilty concerning our brother, for we saw the anguish of his soul when he pleaded with us, and we would not hear; therefore this distress has come upon us.”
22 And Reuben answered them, saying, “Did I not speak to you, saying, ‘Do not sin against the boy’; and you would not listen? Therefore behold, his blood is now required of us.”
23 But they did not know that Joseph understood them, for he spoke to them through an interpreter.
24 And he turned himself away from them and wept. Then he returned to them again, and talked with them. And he took Simeon from them and bound him before their eyes.
Here’s Williams’ take on why Joseph acted as he did.
He loved [his brothers], and therefore sought their spiritual welfare. He acted so as to bring their sin to remembrance, to make them confess it with their own lips, and not just to him and in his presence, for he still concealed himself from them, but to God and in His presence. His detention of Simeon, and, afterwards, of Benjamin, was skillfully designed so as to find out if they still were indifferent to the cries of a captive brother and the tears of a bereaved father. His plans succeeded admirably, his sternness and his kindness both conspired to disquiet them; and his goodness helped to lead them to repentance. — Williams, page 39.
__________
Apparently, everyone coming into Egypt from foreign lands to buy grain had to obtain a direct permit from Joseph before he would be allowed to do so. It might well be that, under cloak of such a purchasing mission, outsiders might enter the land for subversive purposes. Foreign kings might covet Egypt’s wealth and desire to infiltrate and sabotage and possibly invade and plunder the land. It was up to Joseph to carefully screen all such alien travelers to be sure of their purposes. — Morris, page 595.
__________
[Joseph] had been a lad of seventeen when [his brothers] last saw him; now he was about thirty-eight. Furthermore, he was not dressed as a slave, but as a king. Also, he spoke to them through an interpreter (v.23), and so they did not even know he could speak their language.
As did everyone who come into Joseph’s presence, except Pharaoh himself (Genesis 41:43), they had to bow down before him. The did not realize, of course, that in so doing they were making the very dream come true for which they had hated him (Genesis 37:7-8). The word “bowed down” in verse 6 is the same as “make obeisance” in 37:7. — Morris, page 596.
__________
In [chapters 42-45] God “ties together” the various strands of circumstance that are spun in the previous five chapters (from 37:2), bringing the brothers face-to-face with their sin for the purpose of reconciliation and, consequently, refinement in godliness as He continues to mold them into the ideal covenant people that they will one day be (cf. Deuteronomy 10:12-22; Isaiah 1:25-26; Malachi 1:5). This dénouement commences when as a result of the famine—which extended even to the land of Canaan (see 41:57)—Jacob sends the ten brothers of Joseph to buy grain from Egypt. When they arrive, though Joseph recognizes his brothers, they do not recognize him, which situation Joseph then wisely exploits in order to (1) determine whether their collective character has improved and they have moved beyond their predilection to deceitfulness, while (2) ensuring that a connection is established which will ensure their continued interaction. Towards this end Joseph accuses the brothers of being spies, which they of course deny, whereupon Joseph sets a condition to determine whether the truth is really with them. Though initially this condition is that one of them will return to fetch Benjamin while the other nine remain confined (i.e., held as prisoners), Joseph compassionately mitigates this condition (he will not do to them, even for a much shorter period, what they did to him) and confines only one of them, Simeon, while the other nine return to their father Jacob in the land of Canaan. — Wechsler, pages 256-257.
One wonders if Simeon was the one chosen as the hostage because he was a ringleader in the murder of the Shechemites (Genesis 34:25-31) and, perhaps, in selling Joseph into slavery.