Matt's answer is most complete. Allow me to take a different angle building on a dvar Torah I wrote in honor of my older son's bar mitsva this shabbat.
I think the reason Yosef causes so much anguish to his family is to get to one thing. He knew he and his brothers would be the fathers of the entire Jewish people, that all Jews would inherit their traits of character. But he realized there was a big flaw in them: a lack of brotherly love, a lack of ahdut (unity). He could not imagine that they could be the source of the Jewish people with such a flaw and wanted a tikun (reparation). So all he does is to force them to correct this major shortcoming, to force them back into ahdut.
How do we know this is Yosef’s goal? Because as soon as he reaches it, as soon as Yehuda tells Yosef that he will not give away Binyamin, Yosef starts to cry and reveals himself to his brothers.
This cry of Yosef is key. It is not so much a cry of joy, after all how could Yosef’s joy be complete when he hasn’t yet seen his father? I don’t think it is a cry of sadness either. It is the sort of cry that we feel when we touch something very deep, very pure, when we feel something new being created, for instance when we want to cry at a brit mila, when we feel the kdusha (sanctity) of a new Jew coming into the brit (alliance), or at a wedding when we feel the love of a new couple being born. In Yosef’s case this was the cry of feeling the ahdut of the Jewish people being created.
How do we know this? I think we can learn it from another cry of Yosef, a few psukim earlier when Yosef met Binyamin. Rashi explains that Yosef asks Binyamin if he has sons. Binyamin answers yes, 10, and the Torah gives their names: Bela, Becher, Ashbel, Gera, Naaman, etc. When we read these names we wonder why the Torah brings them, but Rashi and the Midrash tell us that Binyamin explains that each name represents a way for Binyamin to remember his brother Yosef. Bela shenivla ben umot haolam, Becher shehaya bechor leimo, naaman shehaya naim beyoter. Every time Binyamin looked at his sons, he remembered the brother he hadn’t known. And all 10 sons of Binyamin together represented for him his brother Yosef. When Yosef hears that he starts crying, of the cry of one who feels what real love is.
So in a nutshell the anguish was justified to create the required unity in Joseph's family - and should be a model for us of the required ahdut in the entire Jewish people.