The brothers sold Yosef into slavery. The Shlah HaKodesh explains that they thought that he and his memory would be forgotten. However, it was not so. A person's thoughts are in vain. Hashem's thoughts are different.
Man thinks one thing, makes a plan and goes ahead.
He thinks it is good. However, Hashem knows better. The plan fails, and it is for the best. The opposite can also happen. Man thinks an event or circumstance is bad.