Managed code is essentially anything that is compiled in to MSIL and run under the CLR. The CLR is a VM that handles memory management and execution of your code and insulates you from low-level interaction with the OS and it resources.
Unsafe code basically allows you to circumvent those safeguards provided by the CLR.