Machines remove balance as a factor. With free weights, the novice must learn to balance the weight while exerting force. This can be difficult and dangerous when, for example, you lift a weight overhead or do squats. Machines ensure correct movements for a lift, which helps prevent cheating when fatigue sets in. Barbells, in contrast, can be swung for momentum rather than lifted slowly and steadily, which works the muscles better.
Machines isolate the specific muscles that are exercising.
This is good for rehabilitating an injury or strengthening a specific body part. Machines can offer high-tech options like varying resistance during the lifting motion. This can tax muscles in ways that a traditional barbell cannot. Changing the resistance on a machine simply means inserting a pin or entering a code. With free weights, plates must be hoisted on and off the bar.