Allah is fair to all of his slaves however this life is a test for all of us yet we all don't have the same amount of time on this test (Earth). Some people get longer time and they live to an older age and some people have less time for the same test as they die at a younger age. I understand that having more time could also mean you are at risk of getting more sins if you do not use your time wisely but equally you have more time to collect good deeds and please Allah. What if in the last few years of your old age you change and decide to leave behind your haram life style and only please Allah? What if you are a non-Muslim and decide you want to revert?
You may say because it is a test, but then what about children? Why are they brought to life on Earth if they will not really be tested because their life is taken away from them while they are a child? This means at this age they do not have any sins so will be granted Jannah.
I mean personally if I had a choice of when to be taken away, I would have chosen a time in my childhood when I was considered an innocent child or even a baby because at this time I do not have sins and so will be granted Jannah. We all will have to die one day and that is for sure so a younger age would be better than going through the pain of trails.