Horses have the ability to "lock" their legs, so can sleep standing up, this is because they are prey animals, and their main defence is to run.
However horses are not always asleep when they rest a back leg, they are simply taking the weight off their feet, like we do when we jut out one hip and rest one foot, thye are relaxing.