I don’t think there’s anything specific in the text that enables us to read Joseph’s mind. However, we can guess.
Joseph’s brothers had sold him into slavery, even though he had doen nothing wrong, other than to articulate a couple of dreams he had that his eleven brothers would bow down to him. The brothers wronged Joseph not only because of his dreams but, also, because he was the favorite son of their father, Jacob/Israel. Some of them even wanted to kill him.
When the brothers came to Egypt (at which time they did bow down to him, as his dreams had predicted), he did not know, for absolute certain, what their intentions were. For all he knew, they had heard of his great status—ruler of all Egypt, second only to Pharaoh—and were envious. Had they come to kill him? Were they only pretending not to recognize him? If so, he had to take the upper hand and demonstrate his absolute authority over them, if only to intimidate them into unconditional submission to him so that they would be much less likely to harm him.
Of course, the text seems to indicate that they really did not recognize him, probably because it had been many years since they last had seen him, plus he also had become “Egyptianized.” However, he may not have been certain of this. After all, he did recognize them.
Another possibility was that, since he was in a position of power, he felt that this was the best opportunity he’d ever have to be vindicated for their unwarranted treatment of him in the past. Maybe he felt completely justified in tricking them and dealing harshly with them, as all of the things he did to them had them cowering in fear. Since it clearly was a miracle of God that he even was in such a high position in Egypt, perhaps he even felt that God had delivered them into his hands—which, indeed, may have been the case—to punish them, as just treatment for all the malicious things they had done to him.
Yet another possibility is enveloped in the notion of “deception” itself. After Joseph’s brothers had sold him to the Ishmaelites, they had deceived their father, Jacob, by causing him to believe that Joseph had been ripped apart by a wild animal and was dead. Nothing could have hurt Jacob more than Joseph’s death, since Joseph was his favorite. It seems only fair, then, that they themselves were deceived, at a later time, by their younger brother Joseph, the one whom they had victimized.
Also, we know that their father, Jacob, was a deceiver (having deceived his own father, Isaac, into giving him the blessing that he had planned to give to Jacob’s older twin brother, Esau). Interestingly, one instance in which Jacob seems to have been “paid back” for that was when Haran, the father of Jacob’s two wives Leah and Rachel, deceived him. Another may have been his being deceived by his own sons, concerning the alleged death of Joseph.
It very well may be that this character trait, deception, was passed onto all of Jacob’s sons. His sons deceived him, and Joseph deceived them. It may have been in their nature. But, of all of them, it would seem that Joseph had the most “right” to be a deceiver, since he is the only one who deceived in return for being deceived. And, certainly, he did not have ill intentions toward his brothers, since he gave them huge amounts of food and silver and, ultimately, wept over them and kissed them.
Furthermore, evidently the primary reason Joseph had instructed that his silver cup placed in Benjamin’s sack, then pretended he believed that Benjamin had stolen it so that all the brothers had to return, was because he couldn’t stand the pain of Benjamin’s departure. After all the years of separation, he did not want to take the chance that he might not see Benjamin—his only full brother—again. So, in this sense, it would seem that his deception may have been due to one of the most powerful motives of all: love.