When the brothers leave Yosef and head back towards Canaan, they are intercepted by a servant of Yosef, who accuses them of having stolen Yosef's goblet. The brothers are shocked and say that if one of them in fact has pilfered the cup, they all will become Yosef's slaves. The servant understands what the brothers are saying but says that only the one who has it will be taken as a slave. Rashi states that the servant initially had said as the brothers did, but was lenient and decided to take only the one who stole the item. Why would Rashi state that the law, which generally does not function based on group punishment, in this case was to punish all the brothers for the sin of one of them?
In order to understand Rashi, one must consider that though a group is not accountable for the theft of one person by the courts of this world, Beit Din Shel Matah, it is held accountable in the heavenly court, Beit Din Shel Maalah. If the members of the group are careful to distance themselves from theft, anyone in their presence would sense their abhorrence for theft and never would consider stealing. However, if one member of the group was to commit a theft, it would mean that they all were not careful enough regarding stealing and therefore all should be liable to divine retribution. Only because of Hashem's great kindness is the rest of the group spared.
The implications of this explanation are quite troubling, as it seems to mean that whenever one sees his friends or relatives being lax in Mitzvot or rules of society in general, he himself is responsible for not setting a good enough example.
Yet one can see the positive aspect of this from Shmuel HaNavi. Upon Shmuel's death, David was forced to flee outside of Eretz Yisrael for the first time. Previously, all he had to do was go to Shmuel, and Shmuel's very presence would dissuade others, even Shaul himself, from exacting upon David what they felt he deserved. Upon Shmuel's death, there no longer were any men of that caliber, and as such David was forced to flee. Shmuel’s shining example warded off David’s antagonists.
While it may not be necessary to go to the extremes that the brothers did, one still must keep in mind the positive as well as the negative influence we can have on one another and be careful as to with whom we associate.
-Adapted from Darash Moshe