What is the meaning of [a dose of adversity is often as needful as a dose of medicine]

Hardship and misfortune may be unpleasant, but they can sometimes have a beneficial effect on the character, especially when people fail to appreciate the good things they have.