Our slick floors are a relatively recent development, so natural selection hasn’t equiped cockroaches to deal with a surface that provides little friction and nothing to reach with its legs. A healthy roach will eventually right itself, usually by using its wings to push off from the floor.
The fact that you always see dead roaches lying on their backs doesn’t mean that they died because they were on their backs. Rather, they ended up on their backs either because they were already dying and so had lost the ability to control their movements, or had died and were pushed over by the rigor mortis of their legs.