The science of acoustics is far too vast and complicated to get into any depth here, but some basic understanding will help you in setting up an optimal space for your studio, wherever it might be.
Sound Absorption and Reflection
As sound travels through the air and interacts with surfaces, it's either absorbed into the material or reflected. Absorption is typically the least of your worries; most of the time it's a blessing in a home studio. Reflection, on the other hand, can be a problem. In a big space, reflections can have an ambient reverb, which is a good thing. Reflections are an essential part of a live concert hall, especially a classical hall, because they produce a natural reverb that is pleasing; reverb processors try to imitate the sound of a big room's natural reflections. But in a home studio that's set up in a small space, reflections can be as loud as the original signal, making it hard to mix and hear the real signal. If you have a space that is overly reflective, the easiest thing you can do is add some materials to absorb the sound and stop the reflections.
Foam for Your Walls
Foam is one of the greatest sound absorbers. Acoustical foam, a special foam designed for studios and sound professionals, is a textured material with raised surfaces and depressions. It does a really good job of cutting down the reflectivity of a room, and is great when mixing with speakers. When you record, the sound of the room is recorded as well; this is called ambience. Certain microphones pick up less ambience than others, but there's always
You can purchase foam from most major music stores or through online catalogs; it is sold by the sheet and can easily be mounted nondestructively to the wall. Acoustical foam does a bad job of soundproofing; so don't try to use it in this capacity.
The Direct Approach
If noise is a problem where you live, try as hard as you can to record direct sources. Electric guitar doesn't have to be miked; there are plenty of processors that do a great job of emulating that sound while the guitar is directly plugged in. The Line6 POD is a famous example of such a processor, and so is the Behringer V-AMP. With certain instruments, such as the drums, you have no choice but to use a microphone. The more direct sources you can use, the simpler your noise problem will be. It's possible to record all direct instruments (guitar, keyboard, bass, drum machine) and mix on headphones, thus creating zero audible sound.