It does less than making HTML whitespace-significant. It's unsuitable for use on HTML markup, because newlines in <script>, inside tags, attributes, comments, etc. should not be changed.
It's only safe and reliable as a part of nl2br(htmlspecialchars()) combo, so a function that does both could have been a better idea.
Plus the actual HTML-escaping tools (htmlspecialchars, htmlentities) do not make whitespace significant.
Though these days, you might arguably be better off with "white-space: pre-line" in CSS instead.