Why this matters
The production reason.
WordPress themes often mix trusted admin content with user-generated content. Escaping at the template edge prevents unsafe HTML from leaking into the page.
Sanitize when saving data, but still escape when printing it because templates are the final security boundary.
Use the escaping function that matches the output context: HTML text, attribute, URL, or textarea.
<h1><?php echo esc_html( get_the_title() ); ?></h1>
<a href="<?php echo esc_url( get_permalink() ); ?>">
<?php echo esc_html__( 'Read more', 'theme' ); ?>
</a>