Generally, our advice to newer users and non-experts is that mixing packages from different releases of Ubuntu is a Bad Idea. We have not tested it, and unexpected results may occur.
"Unexpected results" is a polite way of saying anything can happen. Maybe it works great, maybe your system stops working entirely. We don't know -- that's why we say "unexpected".
We don't usually provide support for mixed-version setups. One purpose of Ubuntu's regular releases is to prevent whole classes of impossible-to-reproduce problems caused by wrong-version packages. If you encounter problems, our typical advice will be to uninstall the wrong-version packages.
However, in the specific case that a package has been dropped and is ONLY available in an older release of Ubuntu, then perhaps installing that package is indeed your best option....
...or maybe not:
- Check http://packages.ubuntu.com that the package is really gone. Sometimes packages get shifted from
main
to universe
or multiverse
(or back). Sometimes the volunteer Debian packager retires and a replacement doesn't step up immediately.
- Check the upstream website for install instructions. Sometimes upstream developers shift from Ubuntu-hosted to self-hosted (or back).
- Check for an updated Snap version. Or Pip or Flatpak. Some upstreams don't package for every available method, or change methods as developers and volunteers come and go.
If your desired software isn't available from ANY other method, then it might be in a slow-progress cycle upstream...or perhaps abandoned/dead by the developer(s). If the former, the software may still be safe to use; take basic precautions to protect your data. If the latter, then it's probably time to look for an alternative.
- Basic precautions: Protect your data and your system from the unexpected effects of wrong-version software: Consider running the software in a disposable Virtual Machine or a Container. Backup your data. Know how to restore from your backups. Have a LiveUSB installer handy.