Up to ten berries appear in your hand and are infused with magic for the duration. A creature can use its action to eat one berry. Eating a berry restores 1 hit point, and the berry provides enough nourishment to sustain a creature for one day.
The berries lose their potency if they have not been consumed within 24 hours of the casting of this spell.
How should I read "up to ten"? Should I roll d10, or does it depends on the spell slot, or can the caster decide how many berries it creates? If it is up to the caster, I can't think of a good reason for creating less than ten.
Since the spell does not provide a roll, it is left to the caster's discretion how many Goodberries are created.
Producing less than ten: Aside from roleplaying factors (which are nearly unlimited), Goodberries are magical for the duration of their existence and are therefore detectable. If one was trying to remain undetected, the spell allows you to produce only what you require.
If a spells description doesn't say that you roll, then you don't roll. Additionally, if a spell has an effect when used with a higher level spell slot, then the spell will have a section titled "At Higher Levels" which describes what the added effect is.
Since the spell description for goodberry has mentions neither a roll, nor a higher level casting effect, the caster chooses a number to create between 1 and 10 when they cast the spell.
It’s up to the caster how many berries are created (up to 10) exactly as stated in the spell description.
Creating less than 10
As to a “reason for creating less than ten,” imagine a prisoner has a short period of time when a guard is distracted. He casts Goodberry to create one berry and eats it. In two rounds, he has sustenance for the day without eating any of the suspect food that is provided, and the guards are none the wiser.