Why does my phone only turn on when it's plugged in?
A common solution to this kind of problem is a complete restore (possibly in DFU mode). Before proceeding, make a backup of the entire content of your iPhone via iTunes or iCloud.
Then, download the latest firmware available via iTunes. Charge the battery entirely before the restore, just to be sure that the iPhone won't shut down during the process.
Proceed by putting the iPhone in DFU; let then iTunes do the rest. 
I suggest you to DO NOT restore your iPhone from backup after finishing. Test everything, including Wi-fi connection. Install an app that shows you the actual battery cycles. Maybe replacing the battery could do the trick. If possible, try to connect to different hotspot; if the iPhone could not connect, maybe another problem is in the antenna.
Let us know.