First, select a wood that is naturally rot resistant. Cedar, Redwood, Teak, etc.
Do not use pressure treated wood as the chemicals that minimize wood rot can leach into the soil. Maybe not a big deal if it's just for flowers, but a definite no for vegetables or other edibles.
If possible, line the box with a plastic liner to prevent soil and water from coming in contact with the wood.
If you don't care about retaining the wood look, exterior paint works great for outdoor protection.
If you want to retain the wood look, oil finishes generally work better than film finishes. A deck or fence stain typically works OK. Sunlight will quickly break down a film finish and refinishing can be difficult. Oil finishes can be reapplied easily as they weather over time.
Spar urethane works OK for outdoor wood. It's a bit softer so it can better adapt to wood movement from moisture and sun in an exterior environment. I used spar urethane on a redwood shelf in our shower and it's over 17 years old now. But it gets minimal overspray and no sunlight.
Better yet is Epifanes marine varnish (you can find it on Amazon). It's designed for boats so it holds up fairly well. I used it on a small table that sat outside for a couple years and it still looks great (we have it indoors now). Of course, it won't last forever and at some point you will need to refinish.
If you really want to go crazy, you could apply a Clear Penetrating Epoxy Sealer (CPES) followed by a top coat of Epifanes varnish. Keep in mind these products aren't cheap and it would probably be more cost effective to build a new planter than splurge on the fancy finishes.
Another option is to build the planter box using PVC lumber. It's available in most home centers now, and you can glue it together using PVC plumbing glue (solvent welding). It can be rather expensive, and comes in any color you want as long as it's white.
PVC also expands and contracts with temperature. Probably not an issue for a small box, but a long board may move a lot. Of course, you can paint PVC to any color you want, but you would need an appropriate primer first.
Of course, the easiest option is to build the box out of something like cedar and just let it weather naturally to a soft grey. You would probably get a few years out of it, maybe longer if you put a plastic liner in it. Then just build new planters when they're too far gone.
Also, don't rule out other materials like metal, concrete, or hypertufa.