Load a specific post if user tries to access 404 page

This is the final code that works. I had to set $wp_query->is_single = true; manually:

add_action( 'template_redirect', function(){
    global $wp_query;
    if ( is_404() ){
        $id = 1; // the post corresponding to hello-world

        if ( $id ) {
            $wp_query->is_404 = false;
            status_header(200);
            header("HTTP/1.1 200 OK");

            $wp_query->query("page_id=$id&post_type=post");
            $wp_query->the_post();
            $wp_query->is_single = true;
        }
    }
}, 999);