The Raised Bed Soil Mix That Actually Drains
The first raised bed I built held water like a bathtub. I had filled it with bagged topsoil because that is what the label seemed to promise, and by the second spring the bottom four inches were anaerobic sludge that smelled faintly of a pond.
What went wrong
Topsoil on its own compacts. In a bed with fixed sides there is nowhere for it to go but down, and after a winter of rain it sets into something closer to clay than to soil. Roots stall in it. Water sits on top rather than moving through.
The mix that worked
What finally worked was roughly a third compost, a third coarse bark fines, and a third native soil dug from the garden. The bark is the part most people skip and it is the part doing the work: it keeps physical gaps in the mix that compost alone loses within a season.
Two things worth saying plainly. This mix settles about two inches in the first year, so overfill it. And it needs topping up with compost each spring, because the bark fraction slowly breaks down and the structure goes with it.
What I would check before building
Dig a hole where the bed will go and fill it with water. If it has not drained within four hours, the ground underneath is the problem and no mix will fix it. Raise the bed higher, or put a layer of coarse rubble underneath before you fill.