I remember when Turbo Pascal 7.0 programs started failing with Division by 0 error cause Turbo Pascal runtime does calibration loop at the start to calculate how many no-ops to sleep for 1 millisecond.
So - your HelloWorld written 10 years ago suddenly stopped working after CPU you run it on got too fast.
Yes, if you change hardware, the software can break (a lot less often now than before though, as hardware changes are a negligible and they usually think about backwards compatibility).
I'm not sure if it's more or less often now, but over decades almost everything breaks one way or another.
Even if your code, OS and hardware had no bugs and was designed perfectly and you keep the same hardware to run you code forever - there's layers under the hardware - the reality outside the computer.
You have written perfectly secure website. Then quantum computers happen.
Countries are created and fall apart. People switch writing systems and currencies. Calendars get updated.
Your code might technically work after 100 years, but with almost 100% probability it won't be useful for anything.
I remember that bug. I also remember that there were generic patchers that could fix any random .exe compiled with Turbo Pascal without even having to recompile it.
So - your HelloWorld written 10 years ago suddenly stopped working after CPU you run it on got too fast.