MIUI is a Xiaomi’s custom made in-house skin for the android operating system and 100% of their phones come with this skin. There are tons of optimisations have been done in the aspects of performance, battery consumption and more. By default, MIUI options have been enabled in the developer options, and you can turn it off whenever you want. But you can see some minor changes in the performance side as well as battery consumption.
With MIUI optimization enabled, we cannot do some things like installing third-party apps. Generally, the system returns an error message (Installation failed) in such cases when we try to install APK’s especially. So, we have to disable it to install YouTube Vanced app. Also, you can turn it on once our work gets done.

How to Install YouTube Vanced in MIUI Devices?
This is simple procedure and you just need is some patience.
Step 1. Download Vanced Manager App from the official page.
Step 2. Now, Tap on the APK file and Allow this source option.
Step 3. Install Vanced Manager APK on your Xiaomi device.
Step 4. Open it and there you can see a popup which says MIUI user detected!

Step 5. Now, go back and open system settings.

Step 6. Tap on the About phone and All Specs.
Step 7. Now tap on MIUI version until it shows you are a developer. That means, it unlocked developer options.

Step 8. Go back to settings main menu and navigate to the additional settings.

Step 9. Now, you can see the developer options and tap on it.

Step 10. Scroll down to till the bottom and there you will find the MIUI optimizations.

Step 11. Disable it and accept warning.
Step 12. Open Vanced Manager.
Step 13. Install YouTube Vanced and Micro G.

Once you successfully installed above two apps, go to the developer settings, and you can turn on the MIUI optimization option.
Top merci bocup
Take good note of every app permissions before disabling/enabling MIUI optimization, because doing so will mess up with most of your apps permissions (I learned this the hard way).