The hobo's comment is designed to show that suffering is relative. The hobo is older than the soliers who are locked with him in the box car, and this gives him more things to compare their situation with.
For example, the young people in the car may feel hungry after not having eaten for a few hours, but the hobo may have not eaten for several days. He can, thus, see the young people's situation as a relatively cheerful one.
Also, please note that in this scene the condition of the soliers in the box car is about to get much worse.
Furthermore, German soldiers are writing on boxcars that will probaby take many nearby Jewish passengers to death camps.
In sum, the situation of the young soldier, who talks with the hobo isn't good, but in relative terms, we have to say that, it could be much worse.
We're left feeling cheerful, but only in an ironic sense.