Yes, it will work and it will be an upgrade.
The 2005 engine will be a "PI" engine while the 1998 is an "NPI".
If the CV is a P71, the other difference will be the oil cooler, but that can be swapped from the old engine onto the newer one.
Might have an issue as the 2005+ are drive by wire throttle control. I'll see what I can find but you may end up needing some wiring done besides the mechanical parts. Such as a 05+ pcm, having it matched to the car etc.. I did find this if it helps. https://forums.tccoa.com/7-engine-4-6l-5-4l/171170-crown-vic-engine-swap.html