<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div class="block1">Текст блока 1</div>
<div id="block2" class="block2">Текст блока 2</div>
<script>
var elem = document.getElementById("block2");
var div = document.createElement("div");
div.innerHTML = "Текст блока 3";
elem.parentNode.insertBefore(div, elem);
</script>
</body>
</html>