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.
So - your HelloWorld written 10 years ago suddenly stopped working after CPU you run it on got too fast.