How to use current_user_can() in register_rest_route()?

You need to pass the wp_rest nonce with the JavaScript request that you send to REST.

This nonce is what passes the information from PHP to JavaScript about which user is making the request.

Example:

<form>
    <input type="text" name="rest_auth_nonce" value="<?= esc_attr( wp_create_nonce( 'wp_rest' ) ) ?>">
</form>

<script>
    jQuery.ajax({
        beforeSend: function (xhr) {
            xhr.setRequestHeader('X-WP-Nonce', jQuery('form').find('input[name="rest_auth_nonce"]').val());
        }
    });
</script>