I remember reading on acoup that in agrarian societies, often they relied on favours and communal sharing in times of bounty. So say if I butchered a hog today, all my neighbours might get some. Not in exchange for something directly, but in the expectation that when I fall on hard times or they get a windfall, they'll do the same for me.
There's probably some potential for freeloading here, but these sorts of communities are likely often right on the edge of survival. If someone develops a reputation for being miserly, that might well result in them starving (or freezing) because they're rejected by their neighbours. So there's an incentive to at least appear generous and pay your fair share.
As parent suggests, this is a popular misconception. It’s a nice story, but its made up. Upon a more thorough historical analysis, evidence suggests that in fact, money came first. Not barter.
The author makes some solid arguments to support this.
Basically, either your proto-society develops ways to track balance of trade[0], or it'll grow a freeloader problem, which will keep it down and possibly even destroy the group. That point comes early enough that it's entirely likely the early societies that didn't develop money didn't grow large enough, and didn't survive long enough, to enter historical record.
--
[0] - Trading via a medium of exchange - that is, some form of money - is just one way to achieve it, but it has the useful property of being self-balancing, thus not requiring shared global state. That is, you don't have to keep official logs of every trade made by everyone in your group to keep things fair and balanced (or even define, update and defend what "fair" and "balanced" means, which is something everyone has slightly different view of) - you can just establish a common medium of exchange, give people freedom to individually negotiate the exchange rates, and you have a self-balancing system.