The advent of machine tools more or less coincides with the adoption of high speed, high accuracy, high power gears as means of power transmission. For obvious reasons if you don't have powered machines you have limited need for high quality gears.
As mentioned in another answer the gears for clocks and watches were originally made by hand with great care and skill using saws and files.
The earliest gears were peg and cage gears which could be made from wood and were used in watermills etc.
There is also a specific process for gear cutting called hobbing which allows accurate gears to be made on fairly simple machine tools.
Gears can also be cast from a pattern, requiring only moderate finishing to an acceptable surface finish and accuracy.
You might also be surprised what level of accuracy a skilled craftsman can achieve.
Indeed CNC technology has tended to improve overall productivity but doesn't do much to improve accuracy and there were automated production processes several centuries before computer controlled machining was a thing. https://en.wikipedia.org/wiki/Jacquard_loom