it does raise an interesting, if morbid question. personally, I think it is fine for someone to kill themselves (or receive assistance in doing so) if they are facing a near certainty of terrible suffering for the rest of their life. the tricky part is the "certainty" bit. many people experience varying degrees of suffering at some point in their lives, but it is uncommon for it to persist throughout their entire lives.
if you are interested in a way to sidestep this specific question, I would point out that the pills are not only for the benefit of the pilots. the measure is also to protect others who might be harmed by information divulged under interrogation.
as for why the pilots in particular, my (fairly uneducated) guess is that pilots inherently have knowledge of more sensitive information than a typical infantry person. while the soldier probably only has knowledge of local troop movements that will be stale in a few days (most US infantry standard procedures and equipment details are public knowledge), the pilot may know classified information about the aircraft they are flying.
[0] https://www.usnews.com/news/articles/2015/02/19/suicide-pill...
Would it be better to be tortured for years? To have your family knowing that your fingernails got ripped out? That you lost your genitals to electrocution?
I'm not sure. Plenty of heroes committed suicide.