My town does fostering for a couple reasons. Military people who get deployed, and also when the shelters are at capacity. You can foster animals until they are adopted permanently, and it helps the shelter because you are paying for their food and care. It can be heart breaking, though, but worth it.
Fostering is when an animal needs to be cared for outside of the shelter. Sometimes it is because the animal has a communicable disease. Sometimes it's because the shelter is too full.
So the foster "parents" take these animals, knowing (and hoping to an extent) to have them only for a bit. Until they get healthy and or adopted.
I adopted a cat from a humane society and my cat was at a foster home. The "parents" were a retired couple who loved animals. They cried after I adopted the cat, but said they knew it was for the best. I regularly sent them updates on how we were doing (with pictures of course).
The shelters give the foster "parents" supplies, food, medicine, etc to adequately care for the animals, and to encourage fostering.
A lot of fostering is by people with time and skills to handle animals with issues: kittens and puppies that aren't weened yet or older animals that need special medical care to get them back on track. Still others may need to learn to trust humans again due to coming from a bad situation. People usually won't adopt animals that are "broken" (need a lot of vet care at first or socialization work). And the average person doesn't have skills to handle circa eight week old baby animals.