(This post is adapted from two questions I answered on Quora.)

Why do a spider’s legs curl up when it dies?

The explanation was provided by Pritesh Kalantri: Spider legs extend due to hydraulic pressure, not muscular action, so when the hydraulics are turned off (as when the spider dies) the muscles that contract the legs have no opposing action, and the legs curl up.

This was new to me, and I quickly found what seems to be the original paper establishing this fascinating fact:  Parry, D. A., R. H. J. Brown: The hydraulic mechanism of the spider leg. J. Exp. Biol. 36 (1959a) 423–433.

A helpful diagram should you decide to test hydraulic pressure in your own spider’s legs. This can be used with live spiders, as needed.
A more detailed view of spider anatomy

1. The blood pressure inside the leg of the house spider Tegenaria atrica has been measured. Maintained pressures of about 5 cm. Hg and transient pressures of up to 40 cm. Hg have been found.
2. The relation between the blood pressure in the leg and the extension torque at the hinge joints has been established.
3. Considerable torques can be developed at the hinge joints during extension, for example, when accelerating a mass fixed to the leg. The transient pressures found to arise in the leg are adequate to account for these torques.
4. The hydraulic mechanism is discussed. The available evidence suggests that the pressure found in the legs occurs also in the prosoma but not in the abdomen, in which case the maintained pressure must be due to the heart. This, however, requires further investigation.

We are greatly indebted to the Cambridge Instrument Company for the loan of a photo-electric transducer; and also to many friends who have supplied us with spiders.

However, a little further research suggests that hydraulic activity is not the only mechanism for spider leg movement.

In large spiders such as A. concolor, the advantage of strong leg flexion remains valid. Here, during jumps and starts, the net propulsive power is shifted more to their front legs. In contrast to jumping spiders, the ground reaction forces of the frontal legs and the second legs are as strong as those exerted by the hind legs.  … It seems that depending on the spider’s body size both hydraulics and muscular leg flexion contribute, to variable degrees, to the propulsion of the hind legs.

Hydraulic leg extension is not necessarily the main drive in large spiders.
J Exp Biol. 2012 Feb 15;215(Pt 4):578-83. doi: 10.1242/jeb.054585.
Weihmann T, Günther M, Blickhan R.

This led inevitably to the next question:  If you accidentally sever a spider’s leg, will the leg bleed?

It does bleed, but there is a special mechanism that prevents too much loss of fluid.  Here is an explanation from a 1957 paper:

Figure 3.  Anatomy of a spider leg, showing the mechanism by which fluid loss is minimized if the leg is severed

Unlike Crustacea and insects, spiders autotomize their legs at a functional
joint and an account is given of the interesting mechanism by which the joint is severed and bleeding restricted. …

‘Autotomie’ was defined by Fredericq (1883) as ‘mutilation par voie reflexe comme moyen de defense chez les animaux’. Usage has since widened the term to embrace all cases of fracture of limbs and other structures at a specific point where structural adaptations associated with the fracture mechanism and reduction of bleeding are found to occur.

… I have shown above (see fig. 3, A-D) that in Tegenaria the coxal muscles are all inserted on to a ring of sclerites which fit into a groove in the proximal rim of the trochanter. The joint fractures between these sclerites and the trochanter, and the coxal muscles then pull the articular membrane proximally while at the same time the sclerites converge on one another (fig. 3, E) so that a comparatively small hole is left in which the blood rapidly clots and which after a day or two is sealed by a brown plate.

— Spider Leg-muscles and the Autotomy Mechanism
Quarterly Journal of Microscopical Science, Vol. 98, part 3, pp. 331-340, Sept. 1957.