Minecraft wiki entry for Villager_(old), associated text: If a brown-robed villager does not have enough food in one stack in its inventory (15 bread, 60 carrots, potatoes, or beetroot, or 45 wheat) and finds fully-grown wheat, carrots, potatoes or beetroot, it will move to the crop block and break it.
If a brown-robed villager has any seeds, carrots, potatoes, or beetroot seeds in its inventory and finds an air block above farmland, it will move to it and plant a crop. They will always plant from the first eligible slot in their inventory.
If /gamerule mobGriefing is false, villagers will not be able to farm.