How to display only one category posts on main page?

Example of a function to remove post category from the home page.

function exclude_category_home( $query ) {
    if ( $query->is_home ) {
        $query->set( 'cat', '-5, -34' );
        }
    return $query;
}

add_filter( 'pre_get_posts', 'exclude_category_home' );

Replace the category ID with the one you want to exclude. Add to functions.php of your child theme.

tech