I've never come across specifics of what
Compile specifically does.
That said, a definition re: programming languages in general provides some insight/understanding:
Compiling is the transformation from Source Code (human readable) into
machine code (computer executable). ... A compiler takes the recipe
(code) for a new program (written in a high level language) and
transforms this Code into a new language (Machine Language) that can
be understood by the computer itself.
Wolfram has developed the Wolfram Language as a very high even
This provides huge advantages to developers/programers, including: conciseness, clarity, ease of debugging, functional organizational paradigm, and (largely) self-documenting code.
In past conversations, with Wolfram staff, they have describe a process of developing Mathematica functions in C level languages. One would expect Wolfram to compile as much of these efforts as possible into as low a level language as possible.
One always has a trade-off in doing this. Generally the lower level of the language, the faster, BUT the lower level of the language the harder it becomes to modify, debug, and refactor the code.
Observing Wolfram's continuing refactoring of the language, especially in developing more abstract level constructs (e.g.,
TemporalData objects) leads me to surmise, that this kind of refactoring/abstraction of the language works hand-in-hand with Wolfram compiling more and more of these constructs and related functions to lower and lower levels of a code stack, with the limit of assembler/machine language.
So, Wolfram, has many incentives to compile everything it can compile.
This becomes obvious, when one runs certain speed tests of Mathematica code vs C, C#, or C++ code. As often as not, when I've done this, Mathematica code just runs faster.
Of course it doesn't do this in every such speed comparison, but it does it often enough to know that the architects at Wolfram do some very smart things.
Thinking through the above, it become clear why certain custom code can benefit from compiling and why Wolfram makes compiling possible.
A stand alone Mathematica function may run compiled code in the background (and run blazingly fast), but such functions almost invariably have connector code to enable them to interact with other
native Mathematica functions.
When you or I develop custom functions using multiple
native Mathematica functions, then we have an increased high-level language overhead.
One could think that using
Compile on a custom function as stripping out any extra/unnecessary high-level language overhead. Doing this can, with a suitable custom function speed up performance considerably.