Improving garden soil takes two things: lots of organic matter, and lots of elbow grease (or a tiller).
At the extremes—a sandy soil that drains too quickly and a clay soil that doesn’t drain—you have to fix the drainage issues first, or nothing good can happen. But even at the extremes, adding organic matter is still the best way to improve garden soil. This is what “Feed the Soil to Feed the Plants”, the mantra of organic gardeners everywhere, means. When you “feed the soil” by increasing soil organic matter, the soil organisms that break it down multiply, and their waste products provide a “micro-manure” organic fertilizer that’s deposited right at the root hairs of your plants. See The Soil Food Web for more information.
In Clay soils, organic matter improves the pore structure of the soil, increases drainage, and increases soil biodiversity by allowing aerobic processes to take place deeper into the soil horizon. See Improving Clay Soil for structural fixes for drainage problems and other issues of clay soil.
In sandy soil, organic matter slows the rate of drainage, improves moisture retention, and increases the biodiversity of the soil ecosystem. See Gardening in Sandy Soil for solutions specific to sandy soil frustrations. In acidic soil or alkaline soil, organic matter “buffers” soil pH, reducing swings in pH caused by adding soil amendments. See Changing Soil pH for more information.
If your garden is in the Goldilocks zone, a loam soil, consider yourself lucky. Loam soil has a nice structural balance between sand, silt, and clay. Even if it had no life in it, loam soil would retain moisture—just by the way its particles stack. But because it retains moisture, loam soil usually has a rich and diverse soil ecosystem. Whether you have clay soil, sandy soil, or anything in between, improving garden soil always involves adding organic matter. At a minimum, you have to replace some of what you take out of the soil by harvesting vegetables.