An ad server is a specific technology that decides what ads to show to individual users and where. They also provide analytics to the advertisers regarding the number of impressions, clicks, etc.
Therefore, ad servers have two main goals:
To show relevant ads to the relevant users at the relevant places: The ad server has information about the publisher and the user who is about to enter the website. It also knows who advertisers are targeting and what websites they want to appear on. Consequently, they match users, publishers, and advertisers for the most beneficial results for everyone.
To help advertisers create better ad campaigns: Ad servers gather analytics about ad performance so that advertisers can improve their campaigns: make more engaging creatives, test what works best, avoid publishers that never bring in any value, consider higher frequency capping, or researching their target audience once again. Analytics also help them to avoid fraudulent reports provided by the publishers.