Nothing to do with cleanliness, on the contrary they can be quite gross also. It’s because eating lunch out is relatively expensive, especially for students. Close to 13€ now after last years inflation craze, whereas cooking at home is more like 2€. It’s not uncommon to see even well paid white collar workers bring food boxes regularly.
Bringing lunches to work used to be a much more common meme in the US. (But maybe it still is among blue collar workers.) Does seem to have faded out a lot though.