But. Its not cheaper.
Lets take your numbers.
40/month for the rented machine, thats 480 per year.
Compared to your guess of 200/year for your own machine.
You could buy your dream machine at 600 and break even after 2.14 years. After that, you are saving money AND you have your dream machine.
Lets expand it. Dream machine at 1000 and 270/year electricity.
Break even after 4.7 years.
So if you run this server for ~5 years, it doesnt matter if you self host or rent. Except you own the hardware if you self host. And you can change it. Experiment. Upgrade. Sell.
Even better, with self hosting you only pay for used electricity. Summer and you don't use the server much becauae you are outside? Less electricity, less costs. Rented its always the same.
And let me give you a tip: get a second machine, a thin client for those small always-on-websites and things.
Thin clients are often well below 20W and you can just shut down the main server if you don't use its power and let the thin client do the important stuff.