The purpose of muscle stimulation in most instances is to help a patient relearn how to move muscles to restore function, such as the simple process of picking up a cup of coffee. The correct term for this type of function restoration is to use a "Functional Electrical Stimulator" or F.E.S. unit. Most FES units are prescribed by a physician to be used following a stroke, or in some situations an injury that resulted in partial denervation, some nerves destroyed or damaged but not all and some have remained intact.
When there are surviving intact nerves then our body, through a process known as "muscle reeducation" , learns how to use the surviving nerves to accomplish tasks that formerly were easy to do. The brain, with the use of the FES unit, is taught how to use the nerves to be able to pick up and drink a cup of coffee for an example. The stimulator actually stimulates the nerves which in turn is also teaching the brain what impulses to send to the surviving nerves so the task can be accomplished.
Most "muscle stimulation" is for the purpose of reducing swelling or in the case of a casted patient, to retard some of the disuse atrophy. The stimulation of muscle nerves for the edematous patient causes the muscles to "pump" and that action restricts the area of the swelling and the fluid is physically pumped out of the area quicker than the normal process would be.
This video explains the functions of muscle stimulators and functional electrical stimulators: