There are a few things that can help.
Train up rookie soldiers without relying on their Aim
Even rookies can still be pretty effective if you use them mostly for utility items and heavy weapons. Bring them along, stocked with Mimic Beacons, grenades, etc., and take your missions slowly until they're trained up. (If you have the Guerrilla Tactics School, you can skip the part where they're rookies.)
Always be training Psi soldiers
Psi soldiers are extremely powerful, and can be trained without taking them on any missions. From the moment you first build a Psi facility it should never be empty, and ideally it should have an engineer to speed up training. If one of your top soldiers gets killed, swap in one of your Psi soldiers to fill the slot.
As an extension of this, your Guerrilla Tactics School should always be training a rookie into a specific class.
Accept a soldier as a mission reward
Sometimes missions will offer you a soldier as a reward. This soldier will generally come with some ranks already, letting you jump right into the fray with a decent option. The main downside is that you'll need to complete a mission without your dead soldier to earn this. You can take a soldier as a reward before losing anybody if you're worried about this eventuality coming up.
Cross train when you can
If you're looking at a somewhat easier mission, leave one of your top soldiers at home and bring someone lower along. Your best soldiers won't level quite as fast, but in the event of their untimely death, you'll have something to back them up with. Try to let the lower level soldier finish enemies off, if possible, to help them level faster. Getting squad size upgrades is very useful to make this a viable strategy.