Since the codec does not appear in Device Manager at all, I would treat this as an enumeration problem, not a driver problem. No driver can attach to hardware that Windows does not see, so I would stop reinstalling Realtek drivers until the device appears again.
- In Device Manager, click View, then Show hidden devices. Check Sound, video and game controllers, and also System devices, for a greyed out Realtek entry or a High Definition Audio Controller. If a greyed out entry is there, uninstall it, then click Action, then Scan for hardware changes.
- In System devices, also check for Intel Smart Sound Technology. On this board the Realtek codec can depend on that controller, so if it is missing or shows a warning, install the Intel chipset driver from the MSI support page for your board first, then restart, before you install the Realtek driver again.
- In BIOS, turn HD Audio off, save and exit, boot into Windows once, then go back into BIOS, turn it on again, save and exit. You already confirmed it is enabled, but toggling it can force Windows to enumerate the codec again after a BIOS update.
- Do a full shutdown, not a restart. Hold Shift while you click Shut down, unplug the PC for about a minute, press the power button for about 10 seconds, then plug it back in and start it. This clears the Fast Startup state that can keep a device hidden after a failed driver install.
- If it is still missing, check whether the hardware is seen outside Windows. Boot a Linux live USB and check its audio devices, or open the case and reseat the front panel HD Audio connector. If no operating system sees the codec, I would treat it as a board fault and contact MSI support, especially if the board is still under warranty. Do not use Add legacy hardware again, because forcing a driver onto a device that is not enumerated is what caused the blue screen.