January 11, 2021
This class handles two important aspects for your application, namely service registration and middleware pipeline.

Services are C# classes that your application depends on for providing additional functionality, both used by the framework and your application. Examples include logging, database, etc. These services must be registered so that they can be instantiated when your app is running and when it needs them.

The middleware pipeline is the sequence in which an HTTP request is processed.

Startup class contains two methods: ConfigureServices() and Configure(). As the name suggests, the first method is where all the services are registered. The second method is used to configure the middleware pipeline.

The IHostBuilder in the Program.cs class first calls the ConfigureServices() method, and then Configure() method. Finally, the host is created by calling the Build() method on the IHostBuilder. The following diagram should make it clear.
startup
Here is an example of a typical Startup class. 
public class Startup
{
    public Startup(IConfiguration configuration)
    {
        Configuration = configuration;
    }

    public IConfiguration Configuration { get; }

    // This method gets called by the runtime. Use this method to add services to 
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddControllersWithViews();
    }

    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
    }
}
You might be wondering why you need two separate classes to configure your app: Program and Startup. Why not use a single class?

Roughly speaking, the Program class is used to configure the infrastructure, such as HTTP server and configuration. Startup class defines the services used by the app, and the middleware pipeline. Most often, after you add a NuGet package, you will be updating the Startup class to add new services.