Honest question: how do we know they are grouchy and instead we aren't just annoying. I have a kid but kids can get on my nerves, when I'm 90 I could imagine 40 year olds annoying me in a similar way.
Watching friends and loved ones die while an individual's body falls apart isn't something many people find particularly easy.
I didn't say it as a moral judgement or anything, just that this is something that has been observed since the dawn of time.
Grouchiness may be correlated with age but not all older people are grouchy. Maybe it's actually caused by feeling useless and unloved.
My elderly mom can switch pretty quickly from easygoing and fun to grouchy when I inadvertently treat her like she's not quite capable of managing her own life. She'll be the first to admit that it's starting to become true, but it's a fine line. I think old people become more grouchy the more young people treat them like they're old and useless, or stupid.