Achieved. My mistake were I need to wait the WebView2 to complete. The correct code is:
std::string htmlContent = R"(
<html>
<body>
<h1>Hello world!</h1>
</body>
</html>
)";
MyWebView.EnsureCoreWebView2Async().Completed([MyWebView,htmlContent](auto&&, auto&&) {
MyWebView.NavigateToString(winrt::to_hstring(htmlContent));
});