Although they can both act as adjectives, have the same basic meaning of “smaller,” and are sometimes treated interchangeably, these two words aren’t exact synonyms.
less, adj. smaller in amount
fewer, adj. of a smaller number
For the most part, less appears with singular nouns and non-count nouns, while fewer modifies plural nouns and count nouns.
We ate less chocolate, but she ate fewer bananas.
They saw less water, but we saw fewer flowers.
It gets a little tricky with numbers and “than” phrases (fewer than/less than). If the number modifies a noun, it usually takes fewer, but if a number is in a “than” phrase by itself or as part of a measurement, it uses less.
She baked fewer than two cakes, but you baked less than two.
You grew fewer than three carrots, but he grew less than three inches.
Further reading: Nouns