Machine tools to cut, shear, bore or grind metallic parts for use in the manufacturing sector have existed even before the Industrial Revolution. But early machine tools were driven by hand using levers and gears; later on, electric motors and hydraulic systems were used, and now computers are used to control them. Before understanding a CNC machine, it is better to have some know-how of what numerical control is.

Numerical control refers to using an algorithm or computer program to control a machine tool. In other words, a set of instructions containing numbers, symbols, and letters is used to program the machine to perform a certain task. Numerical control machines were invented in the 1940s and 1950s. Although electronics was still in its infancy, motors were utilized to guide the machine through a set of dots on a punched tape. Later on, digital computers were implemented. This gave rise to the modern CNC machine. CNC stands for computer numerical control.

The CNC Machine

A CNC machine consists of a microcomputer such as a microcontroller or a programmable logic controller (PLC), fitted on the machine itself, and programmed with a set of instructions to carry out the specified task.

The main difference between a numerical control machine and a computer numerical control machine is that numerical control involves the use of punch cards, whereas in computer numerical control, a computer is used. CNC machines store the program in their memory unit.
Mazak Variaxis machine

Benefits

CNC machines offer greater benefits over a traditional NC or numerical control machines. They are more flexible as they can be easily reprogrammed by a computer programmer to match the new job. Furthermore, they are cost-effective and much faster owing to the blazing speeds of modern computer processors. They also have more storage capacity and are highly accurate.

How do they Work?

CNC machines work exactly like robots; in fact, they are robots because they are automated and robots are controlled by computers as well. When the program or set of instructions are written to meet the requirements of the task such as cutting metal, the computer executes the commands and performs the task at hand. CNC machines work with drilling machines, lathe machines, turning machines, and milling machines.

Machining tasks like cutting metal parts to shape them require highly skilled operators; that can be expensive. On the other hand, CNC machines don’t need many people to run them. It just needs an operator who can write and load the program into the machine and fit it with the appropriate tools. After that, the machine takes over as the task is completely automated.
 
Sources
http://www.brighthubengineering.com/manufacturing-technology/55787-what-is-the-cnc-machine-how-cnc-machine-works/
http://www.thomasnet.com/about/cnc-machining-45330503.html
http://wings.buffalo.edu/academic/department/eng/mae/courses/460-564/Course-Notes/CNC%20notes.pdf
http://www.technologystudent.com/cam/cnccut1.html