You've got to hand it to earthworms. Silently, without fanfare, they transform organic matter in your garden soil into nutrient-rich humus that plants can use. People typically think of earthworms as outdoor creatures, but you can actually raise them indoors, too, and use their castings to improve your soil indoors and out. Why bother? Because earthworm compost or "castings" contain five times more nitrogen, seven times more phosphorus, and 11 times more potassium than regular garden soil. The castings also contain microbes that can help plants fight disease.
The process of composting with earthworms has a scientific name: vermicomposting. You can use the rich worm castings in the garden, or in container potting soils. Plus, raising worms indoors is a fun winter project and a way to recycle vegetable scraps from the kitchen. If you think earthworms don't produce a lot of compost, consider that the average red wiggler worm consumes its weight in kitchen scraps daily. Multiply that by a couple hundred earthworms and you've got a compost factory!
Here's how to get started.
The Container

You can build your own worm bin or buy a commercial product. Bins can be plastic or wood. If you're building your own, make it as large as is manageable in your space but only 8 to 12 inches deep. Earthworms feed on the top layers of the bedding.
Drill 8 to 12, ¼-inch-diameter holes into the bottom and sides of the bin for proper aeration and water drainage. Drill more holes if you are using plastic or if the bedding stays consistently wet. Place a tray under the bin to collect the earthworm "tea" that drips from the bin. This tea makes an excellent foliar fertilizer for houseplants.

Vermicomposting, or raising earthworms in containers, is not just a great way to produce rich compost, it's also a fun activity for kids.
The Bedding

Your worms need more than just the occasional banana peel or leftover lettuce leaves to thrive. They need a bedding material that will retain moisture while providing food, air, and a home for the young wigglers. Some good options are shredded cardboard, newspaper, or coir (coconut husks); and peat moss. Moisten the bedding before placing it in the bin and wring it out until it has the wetness of a well-wrung sponge. Place 4 to 6 pounds of bedding in a 4-foot-square worm bin. Fluff and occasionally mist the bedding with water if it appears dry.
Loosely cover the bins to keep earthworms in the dark. They need temperatures between 40°F and 80°F to survive, so place the bins in a cellar, warm garage, or even under the kitchen sink!

Red wiggler worms are well-suited for vermicomposting. They like warm temperatures and shallow soil.
The Worms

Although all earthworms eat organic matter, the best type to use in vermicomposting is red wiggler worms. Red wigglers thrive in temperatures between 55°F and 77°F — just like most homes. (Worms from your garden, such as night crawlers, prefer cooler soil temperatures and deeper soils.) You can buy red wigglers through the mail or at a local bait shop.
How many pounds of worms you use depends on how much waste you produce. One pound of red wiggler worms (about 1,000 worms) can digest a half-pound of veggie scraps a day.
The Food

There is a long list of goodies you can feed your worms including vegetable scraps, fruit peels, coffee grounds, tea bags, crushed egg shells, and even leftover pasta. Worms don't like garlic, onion, and spicy foods. Also, avoid adding meats, fish, fatty and oily foods, and bones. Chop up the scraps into small pieces and lay a thin layer on the top of the bedding. The worms will come up to feed in the dark. Add a small amount of gritty material such as potting soil or cornmeal to help your worms digest their meal.

The Can-O-Worms is a commercial worm composting bin that can be used outside, or in a garage or shed.
The key is to start slowly, adding small quantities of scraps until the worm bin gets cranking. If you notice bad smells, cut back on the food scraps. Unless you have a large bin, or several bins, don't expect your worms to eat every scrap in the house.
The Harvest

After 3 to 4 months your worms should have eaten all the bedding material and the food scraps you've been feeding them. The top layer of the matter should turn dark brown and will have the consistency of chunky sand. It's now time to harvest the castings. The simplest method is to push the castings to one side of the bin, and add more bedding and food scraps to the other side. After a few days, the worms will migrate to the new bedding and food scraps. You can dig out the castings and add more bedding and food. As you harvest the castings, make sure you pick out any stray wigglers and return them to the bin.