Minecraft wiki entry for Villager, associated text: If a farmer villager does not have enough food in one stack in its inventory (15 bread, 60 carrots, 60 potatoes, 60 beetroots, or 45 wheat) and finds fully-grown wheat, carrots, potatoes, or beetroot, the villager moves to the crop block and harvests it.
If a farmer villager has any seeds, carrots, potatoes, or beetroot seeds in his inventory and finds an air block above farmland, the villager moves to it and plants a crop. They always plant from the first eligible slot in their inventory.
Farmer villagers use and pick up bone meal. They also fill their composter with seeds.
If /gamerule mobGriefing is false‌[Java Edition only], villagers cannot farm.
Farmer villagers cannot turn dirt, grass blocks, or dirt paths into farmland. Nor they pick up any hoes to till the blocks.
If a hoe is placed into a farmer villager's mainhand or offhand via commands, they still cannot till any blocks.
Farmer villagers often share their crops and food with other villagers if they have any extras.