It's hard to find reputable sources on this issue, but let me present the two different takes on it that I found. According to this article:
Cockroaches, apparently, have bulky bodies (composing of 3 heavy body
segments) which are only supported by 6 long thin legs, As they die,
they lose muscle-control causing the leg muscles to contract. As a
result, the legs are forced to be pulled beneath the body causing them
to lose their balance, and topple over. This also explains why
cockroaches on the wall fall off when they were crawling on the wall
and got sprayed with insecticides.
Is flipping over always the case?
No. There is still a possibility for a cockroach to die without
toppling over. However, it is inherent upon these insects to
involuntary experience muscle contraction and end up lying on their
back upon dying.
On the other hand, this article addressing specifically this question takes a slightly different take on the issue (point 3 is similar to the previous article):
I've been discussing the subject with the crack bug scientists at some
of the nation's leading institutions of higher learning, and we've
formulated the following Roach Mortality Scenarios, which represent a
major step forward in our understanding of roach postmortem
(1) Roach has heart attack while crawling on the wall. OK, so maybe
roaches don't have heart attacks. Just suppose the roach croaks
somehow and tumbles earthward. The aerodynamics of the roach corpse
(smooth on the back, or wing side; irregular on the front, or leg
side) are such that the critter will tend to land on its back. Or so
goes the theory. Admittedly the study of bug airfoil characteristics
is not as advanced as it might be.
(2) Roach desiccates, i.e., dries out, after the manner of Gloria
Vanderbilt. This is what happens when you use Cecil's Guaranteed Roach
Assassination Technique, described elsewhere in this archive. The
roach saunters carelessly through the lethal borax crystals, causing
him to lose precious bodily fluids and eventually die. Since this
process is gradual, it may happen that the roach simply conks out and
dies on its belly.
(3) Roach dies after ingesting potent neurotoxins, e.g., Diet Coke,
some traditional bug poison like pyrethrum, or the food served at USC
cafeterias. Neurotoxins cause the roach to twitch itself to death, in
the course of which it will frequently kick over on its back, there to
flail helplessly until the end comes. No doubt this accounts for the
supine position of the deceased cockroaches you observed.
I found no serious articles claiming this to be simply not the cases.