In the hind limb, the patella can be hooked over a ridge on the femur, holding the stifle joint in extension. Tendons running down the leg then hold the lower joints in place as a linked chain. The forelimb has its own passive arrangement of check ligaments. Together these allow a horse to remain standing while the postural muscles largely relax.
The adaptation suits a prey animal on open ground, where the seconds required to rise from lying down are a real cost. Horses rest standing for much of their sleep, alternating which hind leg carries weight, and a herd will typically keep some animals upright while others lie flat.
What standing rest cannot provide is rapid eye movement sleep, which requires the loss of muscle tone. For that a horse must lie down in lateral or sternal recumbency, usually for short bouts totalling less than an hour a day. A horse prevented from lying down, by pain or by an unsafe environment, becomes REM-deprived and may begin collapsing while standing.

