The idea is to let the user see the effect of changes without closing the dialog.
- classic model: OK closes the dialog and applies changes
- instant model: effect of changes is visible with every click and key press (e.g. typing a letter updates search results)
- Apply button: half the deal with a tenth of cost.
Note that the user model is different. In classic, the user knows what he wants and knows what change is needed to achieve that. In instant, the user plays with knobs until things look good. That's a significant gap that affects large parts of the UX and program design.
The apply button allows much less effort in implementation, e.g. no undo information required when user clicks cancel, and relatively few code structure changes are required compared to the classic model, while delivering half the experience. Of course, it's limited. Often, the dialog is in the way of the thing you need to see, it still takes some mouse clicks, etc.
So in most cases, it's a transitional pattern. There are some cases where "instant" doesn't work, or requires extra complexity, e.g. when Apply takes 500ms or more, you may need to move the update to a worker thread.