Surprisingly WordPress always seems to leave the box unchecked when loading a page, so a user has to keep checking it each time they want to leave a comment to keep their name saved. With this simple JavaScript snippet the checkbox will be prefilled if a user has previously checked it and submitted a comment.
<?php
/**
* Automatically tick the "Save my data in this browser" checkbox on comments if it was ticked before.
*/
add_action('wp_footer', function() {
if(is_single() && comments_open()):
?>
<script>
if(document.cookie && document.cookie.includes('comment_author_')) {
document.getElementById('wp-comment-cookies-consent').checked = true;
}
</script>
<?php
endif;
});