The lifespan of a computer keyboard will depend on how much use it sees. I use my keyboard daily and type a lot. So at most I get around 3 years out of a cheap keyboard before needing a new one.
After 3 years of constant use I find my keyboard keys start to get hard to press down and it gets very hard to use.
3 years is a good time frame to replace a keyboard if it's very cheap one.