How to exclude events (custom posts) from search, if the start date has already passed?

This works, when I put it in functions.php.

function wpq_modify_search( $q ) {
    if ( ! is_admin() && $q->is_main_query() && $q->is_search() ) {
        $meta_query = [
            'relation' => 'or',
            [
                'key'     => '_event_start_date',
               'value' => current_time( 'mysql' ),
                'type' => 'DATETIME',
                 'compare' => '>=',

            ],
            [
                'key'     => '_event_start_date',
                'compare' => 'NOT EXISTS',
            ],
        ];
        $q->set('meta_query', $meta_query );
    }

}

add_action( 'pre_get_posts', 'wpq_modify_search' );

I don’t understand this code though, please can someone explain it please?