What is the exact wording of the warning?
If it says Privacy Warning, when connected to the router tap on the i next to the network name and turn on Private Address, then turn off Wi-Fi for a few seconds, and reconnect. Alternatively, if this is your home router you can safely ignore the warning; it is only a privacy issue when roaming on Wi-Fi public hotspots. (The phone warns anyway, because it doesn’t know that it’s your home network.)
If it says Weak Security this is NOT an iPhone problem; it is a problem with the settings on your Wi-Fi router.
A "Weak Security" notification means that your Wi-Fi router is not configured correctly. There is a new feature in iOS 14 and later and Mac OS Big Sur (11) and later that checks and displays a message if your router is not using the most up-to-date security settings. Note that your router has always had weak security, you just didn’t know about it until now.
See this Apple support article for how to configure it correctly—>Recommended settings for Wi-Fi routers and access points - Apple Support, specifically the section headed Security. And don't forget to configure your range extenders (if any) also!
After you change the router settings you should Forget the network in your phone settings and reconnect.
Note also that weak security does not interfere with using Wi-Fi, it is just a warning. Your Wi-Fi should still work normally, and, if it doesn’t, it is not because of the weak security message.