What the palladium layer is doing
Nickel diffuses. At reflow temperature it moves into the gold and, on a bonded pad, into the bond interface. Nickel oxide at that interface is what weakens a gold wire bond and what makes a joint brittle after aging. Palladium sits in the way. It is hard, it does not oxidize at soldering temperatures, and it bonds to both the nickel below and the gold above.
The second effect is that palladium removes the black pad mechanism. There is no displacement reaction eating the nickel, because the gold lands on palladium rather than on nickel. A board that has ENEPIG is not immune to corrosion, but the specific failure mode that plagues ENIG is designed out.
Cost is the trade. Palladium is more expensive per gram than gold, and the bath needs its own analysis and its own line time. The layer is thin, so the material cost per panel is smaller than the price difference suggests; most of the premium is bath control.