Creating a link to the first post in a category

Given a category ID, in this example as the variable $cat_id, you would do this by querying 1 post in that category, ordered by date in ascending order (oldest first). Then use that result to get the permalink to that post.

$posts = get_posts(
    'numberposts' => 1,
    'order' => 'ASC',
    'cat' => $cat_id, 
);

if ( ! $empty( $posts ) ) {
    $url = get_the_permalink( $posts[0] );
}

To get the latest post in that category just change ASC to DESC.