"It was not you that sent me here, rather it was Hashem, and He has made me as an advisor to Pharaoh, a master to his entire house and a ruler over the entire land of Egypt" (Bereishis 45, 8). Yosef recognized that the entire sequence of events that led up to this phenomenal moment were all a product of Hashem's hashgacha pratis, and not a result of his brother's decision to sell him. By selling him, the brothers had intended to rid themselves once and for all from Yosef and his farfetched dreams, and in reality their actions were the very impetus for the fulfillment of those dreams. The hand of Hashem was clearly responsible for all that had transpired.
Rav Wolbe comments (Shiurei Chumash Parshas Vayeishev 37, 14) that many people are confused as to what exactly bechira is. Do people have free will, and Heaven lets things play out in accordance with their actions, or is everything preordained from Heaven, and therefore, it doesn't make a difference what a person chooses? He explains that the answer can be found in the Chovos Ha'levavos (Avodas Elokim Chap. 8). He writes that in reality
both sides of the coin are true: everything is up to our bechira and at the same time it is preordained by
Hashem. In other words, we must make decisions as if we are the sole ones effecting the outcome of our
actions, however, in the final analysis, Hashem will arrange things the way He deems fit.
For example, when a boy of marriageable age starts dating, he has no idea which girl Hashem has in mind for him. Nevertheless, this lack of knowledge should not at all affect his decision. As with all decisions, he must analyze the topic at hand from all sides, consult with knowledgeable individuals and come to a sensible conclusion. At the end of the day, Hashem might just make things turn out differently than expected, but that does not exempt us from our obligation to act rationally.
We can't know what Hashem wants, but He gave us seichel to try to figure out what is best for us. Even if things turn out differently, we can be sure that this is what Hashem wants, and not only that, it is what is truly best for us.