How much would it cost to build Drupal?

Drupal comes with a lot of features available out of the box.

It has a flexible system to create complex content models with different content types and fields, rich media management and Views - a visual query builder - to create lists of content.

It has the JSON:API module to expose your content via an API for use by other systems, such as mobile apps.

It has user management, authentication, password resets, roles and permissions.

It has configuration management to easily manage settings and configuration between environments and to provide traceability.

It has the Layout Builder to create page layouts with a drag and drop interface and a built-in WYSIWYG editor for entering rich content.

These are just some of the features I could mention.

Running cloc on Drupal's core directory shows 18,289 files and 1,095,970 lines of code.

If you were to get someone to build a CMS from scratch with the same features, how long would that take?

How much would it cost?

This is what you get for free by using free and open source software like Drupal.