A person can be killed instantly through many different means.
As we know it, to be killed painlessly, is to be killed instantly.
If you instantly destroy a person's entire brain then they died without pain.
Yet the most effective ways of instantly destroying someone's entire brain are considered inhumane.
If instantly killing someone by smashing their head with a massive rock, or shooting them in the brain stem is inhumane, then there is no humane way to kill someone at all.
To understand why it’s legal in the USA you have to first understand how the US’s government is structured. The Federal Government actually doesn’t hold that much power, the most power is held by the States which decide on issues like this for themselves.
https://www.pewresearch.org/short-reads/2021/07/19/10-facts-about-the-death-penalty-in-the-u-s/
Oh, I understand quite well why it’s legal in the US. It’s been a topic of some debate my entire life here.