For most of these questions, the Runtime Environment as it seems to be described in your book is more easily understood by comparing a low-level language like C, to a VM (Runtime Environment) language like Java.
How does compiler execute the code, it is only supposed to generate
the intermediate code right?
Your quote doesn't say the compiler executes the code. It says that it can start up a RTE which takes over. For lower level languages that don't use a VM/RTE, it can signal the OS to begin execution of the program. In either case, this is a hand-off, not the execution itself.
And does it create runtime environment? I mean there's not a virtual
machine that the program runs on, it just runs on your computer right?
When does it create a runtime environment?
Practically speaking, the interpretation of these terms is largely dependant on the language in question.
All programs run on the OS, which manages access to hardware for running programs.
In a low-level language like C, the Runtime Environment as a concept is arguably indistinguishable from the OS itself. Memory alloc/dealloc requests are made directly from the program to the OS.
In a high-level language like Java (the most commonly references "VM" language), the Runtime Environment as a concept is used loosely to refer to the program that sits between the executing program and the OS. The Java Runtime Environment consists of the Java Virtual Machine (which handles memory management requests to the OS, among other things), some libraries, and utilities.
Isn't memory managed by the operating system? Why is allocation of
storage done by the compiler and at what point? Probably what
variables are needed and how much may be known by the compiler but,
how does it communicate this information to the OS?
Hardware memory address reservation is managed by the OS.
Specifics of the complexity of memory management intervention provided by the RTE is going to be specific to the RTE implementation. Some provide more features than others.
The Java Virtual Machine makes the alloc/dealloc requests to the OS on the behalf of the executing programs. It also has a Garbage Collection cycle which looks for and frees memory reservations that are no longer being used by the program, rather than holding them all until execution halts.
In C, it is the explicit responsibility of the executing program to make these requests to the OS. Memory requested remains reserved until the program halts, or the memory is explicitly released by the program.