- The MBR gets written when Grub is installed, or when any other boot loader is installed
- What the MBR contains depends on the boot loader that is installed. If Grub is installed, it can be used to boot both Linux and Windows.
- Grub is (partially) installed in the MBR. The code in the MBR knows where to load the rest.
Having said that, I must point out that the MBR is quickly losing significance. It is not used to boot machines with UEFI firmware (unless the legacy compatibility mode is used). Practically all new PCs are shipped with UEFI today. UEFI machines have a different way of booting, and also use a different partitioning scheme, that does not use the partition table in the MBR.