This phrase is usually used as an expression of comfort, telling someone that things could be worse and that they could be in an even more difficult or unpleasant situation. It implies that even though the situation is bad, it could be even worse, and to take comfort in the fact that there are more difficult, or more dangerous, situations that could have occurred instead.