In general, the issue that Android phone fails to connect to Wi-fi is caused by several main reasons. These reasons are:
Software error/bugs. It is possible that the operating system you are using is too old and you need to update your software. A software update can fix the bugs in the previous system normally.
Poor Wi-fi Signal. Sometimes the signal of Wi-fi might be too weak to be detected or used. So you can change your position to receive the Wi-fi or check the speed of the connected network.
The router does not work well. The Wi-fi on mobile phone comes from router so it won't be able to work well when the router goes wrong. Thus, just check the status of router at first.