Some ransomwares, like PETYA, are encrypting the MBR and asking for a ransom. I don’t understand why Secure Boot isn’t preventing that of happening.
Secure Boot prevents the computer from booting if the bootloader (stored in the MBR, on MBR disks) or other boot-time code is tampered with. It doesn't actually prevent such tampering itself. The purpose of Secure Boot is to prevent malicious boot code from compromising your computer invisibly - think spyware that records your keystrokes and files - not to protect you from malware that tries to deny you access to your computer.
In InfoSec terms, Secure Boot provides integrity - you know if something has been tampered with - and can also provide authentication (if you only trust one signing key, you can be pretty sure that if your computer boots its boot image was signed by that key). It does not provide availability (protection against denial-of-service attacks, which is basically what ransomware is) or authorization (access control checks that control what software is allowed to do) except in the sense that it prevents the machine from booting if the boot image is tampered with.
You can usually block writes to the MBR from the firmware (BIOS or (U)EFI).
SecureBoot do protect against tampering the boot code. This is what Microsoft writes in its blog:
UEFI Secure Boot is the security standard that uses hardware features to protect boot process and firmware against tampering. This protection will stop the dangerous disk encryption executed by Petya with a bootloader. After Petya’s forced reboot, a machine with Secure Boot will detect the anomalous bootloader and prevent further execution, containing the damage and preventing the very dangerous encryption of disk sectors leading to a complete loss of data.
Further in this blog in the boot recovery options MS clearly describes sample message that is showed to user after such prevention and gives recommendation to use startup recovery for that.
So, probably chosen answer is not technically correct, or was intended to latest (unrecoverable) Petya modifications.