Short answer. No. Any testamentary provision allowing excavations that cause danger to an adjacent land or building is void. If the excavation your father's will authorized would genuinely endanger the neighbor's retaining wall, that specific provision is not enforceable, regardless of what the rest of the will validly provides.
What the law says
Any stipulation or testamentary provision allowing excavations that cause danger to an adjacent land or building shall be void.
Civil Code, Article 685 — Void Stipulations On Excavations. Read the full provision →
The rule covers wills as directly as contracts
The statute names both a stipulation and a testamentary provision in the same breath, making clear that a will is no more able to authorize dangerous excavation than an ordinary contract clause would be. If a provision in a will directs or permits excavation that causes danger to an adjacent land or building, the law declares that provision void outright — it carries no legal force despite appearing in a validly executed will.
What makes an excavation provision void under this rule
The trigger is danger to an adjacent land or building — here, your neighbor's retaining wall. The provision does not need to have already caused actual collapse or damage; the statute speaks in terms of excavations that cause danger, meaning a real risk to the neighboring property's stability or safety is enough to bring the void rule into play, without waiting for the harm to actually materialize.
Voidness attaches to the provision, not the whole will
This article strikes down the specific authorization to excavate dangerously — it does not, by its own terms, void the entire will simply because one clause runs afoul of this rule. The rest of your father's testamentary dispositions can generally stand on their own, while this particular clause authorizing the dangerous excavation is treated as though it were never validly given, because the law will not lend its force to a provision that threatens a neighboring property this way. An executor asked to carry out that specific clause would have no valid authority to do so, and the neighbor is not left to simply accept the risk because the direction happens to appear inside a will.
Why the law treats this as an absolute prohibition
Ordinary neighbor-relations rules generally let landowners negotiate away or accept certain risks through agreement, but excavation that endangers an adjoining land or building touches on public safety in a way private arrangement cannot excuse. Declaring the provision void, rather than merely giving the neighbor a claim for damages after the fact, reflects that the law would rather prevent the dangerous excavation from happening under color of authority than compensate for the damage once a wall has already given way.