Old fashioned windmills were used for grinding things like flour and grain, so they were essentially a giant stone that was spun by the wind, sitting on a giant stone that could turn freely. As the top stone moved, the bottom stone could turn with it, and anything in between was crushed.
Modern electric windmills use a turbine and gearbox to rotate a magnet in a coil of wires. This generates alternating current in the wires, which is used to power things in the electric grid, as well as charge batteries.
Other windmills have operated things like pumps, so seawater could be removed from a section of land, or bellows, so iron workers could maintain high heat in their forges while they worked.