A computer keyboard should last 5 to 10 years depending on how much typing you do and the quality of the computer keyboard.
If you get 5 to 10 years out of a cheaper computer keyboard, then you've got your money's worth although some more expensive and higher quality keyboards can last longer than 10 years, but most people would get a new keyboard anyway when they upgrade to a newer computer.
I replace my computer keyboard every 3 to 5 years as I do a lot of typing and work from home.
Some people can keep their computer keyboard for 8 to 10 years and sometimes only replace the computer keyboard when they get a new computer.
The more typing you do on your computer keyboard the quicker it will often wear out.
I always just buy the cheap but good computer keyboards for less than $20.00 and they last 3 to 5 years which is good enough for me.
Buying a higher quality computer keyboard can be worth it for some people but cheaper keyboards often work just as well, especially if you don't do a lot of typing.