There are a few reasons why your iPhone may not charge properly, here you may need to restart your phone, check your Lightning cable for kinks and breaks, make sure your power supply is working, and if you have checked all these things and still not If it works, there will likely be enough debris in the port to prevent the connector from making a strong connection.
And according to business insider, your iPhone port can get so dirty that it stops working, any time you put it in a pocket or bag, small bits of dirt, dust, and lint may find their way.
And when you insert the cable, it compresses and packs dirt deep into the port, and eventually, it may become so contaminated with debris that it stops working.
How to clean the iPhone charging port:
If you plan to insert anything into the port to pull out the installed dirt, there is one acceptable tool for this job: a toothpick.
1. Turn off your iPhone, you can open the Settings app and tap General, followed by Close.
2. Holding the compressed air upright on the phone can cause any debris to get sucked into it.
3. Turn your phone on and try charging it again, if it still doesn't work, it's time to try a toothpick.
4. Again, while the phone is off, gently insert the toothpick into the port and gently rub it against the inner wall of the port, do not press against the inner wall closest to the front of the phone, because there are fine staples there.
5. After using the toothpick for a while, give the port another shot of compressed air to help remove anything you loosened.
6. If you push some dirt, restart the phone and try charging it.