Because Allah (SWT) has guaranteed to change any unpleasantness and unhappiness into good and pleasant situations; for those who fear God. And God will give sustenance to them from ways which they can never think of [1].
[1] Beharul Anwar, Vol. 75, Page 121.