A popular explanation is that 'nuts' is a corruption of 'knots', and the song refers to gathering bunches of flowers from the hawthorn tree.
Personally, I like to think of it as just a nonsense rhyme, the sort of childrens' song that's always been around.