Question: why do domain names cost money?
Answer: You don't actually buy the domain name, you rent it from your registrar. The price you pay them is for the service of routing the domain name to an actual server. Without that service a domain name would lead nowhere, they have to point visitors to the right server. They need servers to do that, which you pay for.