Hello,
We have done a quick test with your HTML and replaceVariableByHTML, and it's working correctly. Maybe you are not using the required license or phpdocx version.
Please note that you need to use a Premium license with the stylesReplacementType option to keep or mix placeholder and HTML styles when replacing a placeholder with HTML. Please check the documentation available on https://www.phpdocx.com/documentation/cookbook/keep-font-sizes-templates-importing-html
Regards.