What does the Torah mean when it writes that "Hashem was with Yosef"?
Targum Onkelos and Targum Yonasan: It means that all his endeavors were crowned with Divine help.
Seforno: Hashem protected him from all those who would do him harm.
Da'as Zekenim #1, Hadar Zekenim #1: To teach us the contrast, that as opposed to a person, who sides with his friend when the friend is on top, and casts him aside after he is demoted; Hashem was with Yosef in Potifar's house, when he was second to the king, and with him even in the dungeon. 1
Da'as Zekenim #2, Hadar Zekenim #2: A parable for this is a man who had 10 sons in 10 countries - he abandoned all of them, and went to the youngest, who was weak and needed help more than all of them.
Da'as Zekenim #3, Hadar Zekenim #3: A parable for this is a man who had 10 donkeys laden with wine in Reshus ha'Rabim. One of them entered a Nochri's house. He abandoned all of his donkeys and pursued the one that entered the Nochri's house, lest his wine be poured to idolatry. So Hashem was with Yosef in the Mitzri's house, to prevent him from learning from their ways.
Malbim: It means that his endeavors were crowned with supernatural success - over and above his natural successes ("va'Yehi Ish Matzli'ach").
Ha'amek Davar: Hashem protected him from sinning.
And Yosef was unlike other people, who fear Hashem when they are poor, but not when they are rich. Yosef feared Hashem when he was in his master's house (e.g. "v'Eich E'eseh... v'Chatasi L'Elokim" (39:9)); and also when he was king ("Es ha'Elokim Ani Yarei" (42:18)).
What are the connotations of, "va'Yehi b'Veis Adonav ha'Mitzri"?
Seforno: It means that Yosef served Potifar permanently in his private quarters. Ohr ha'Chayim - A great person chooses only proper slaves to serve in his house, and only the most elite to serve him himself. Through this, Yosef was spared from the painful life of lowly slaves. 1
Oznayim la'Torah: In spite of the change from being the Ben Zekunim in the house of Yaakov, to becoming a slave in the house of Potifar - a man who purchased beautiful slaves for homosexuality - Yosef accepted the situation in which Hashem had placed him and served his master faithfully, placing his faith in Ha'Kadosh-Baruch-Hu. 2
Malbim: Yosef's success was in spite of two barriers. (a) He was in his master's house; normally, success pertains to someone who is independent. A slave's success is only due to his master's success. (b) He was in the Mitzri's house, which inhibits success of Hashgachah. 3
Ha'amek Davar: It was because Yosef was in his house, that his master noticed his success.
See also Ohr ha'Chayim.
Indeed Yosef's success in every situation that he found himself was due to the fact that he accepted the will of Hashem and, on the understanding that, if Hashem had placed him there, that is where he had to be and he proceeded to apply himself to the best of his ability to fulfill whatever Hashem expected of him. Refer also to 39:20:4:1.
Perhaps this is because Egypt epitomizes the [seeming] lack of Hashgachah - they take water from the Nile river, and do not rely on Hashem for rain. Refer to Devarim 11:10:1:2 and notes. (PF)