JSFiddle - React, Tailwind, and code Playground

HTML

<div class="contentBox">
    <p>I have some content that is good to read</p>
</div>

JavaScript

String.prototype.insertTextAtIndices = function (text) {
    return this.replace(/./g, function (char, index) {
        return text[index] ? text[index] + char : char;
    });
};
var range = {
    25: "<span style='color:red'>",
    40: "</span>"
};

document.getElementsByTagName("p")[0].innerHTML = document.getElementsByTagName("p")[0].innerHTML.insertTextAtIndices(range);