Motoko does not allow direct access to the System API, as that would easily break all safety properties of Motoko. Instead, it wraps the Systems low-level features in (hopefully) more convenient and safe higher level abstractions.
For example, it manages stable memory automatically for you, via the stable variables.
There are plans to offer more manual access to stable memory, though.
Just to be clear, there is a distinction between functions provided by the System API and functions provided by the so-called ManagementCanister.
Your code for accessing the ManagementCanister and its functionality (like IC.raw_rand()) is correct, but much of the System API (including ic0.stable_size) is, by design, not accessible from the ManagementCanister but is instead made available to wasm programs as imported Wasm functions.