I had the same problem as you. Did you install any apps such as "McAfee Mobile Security"? under "Wifi Security", you gota off it and it works for me. Hopefully it will for you too!!
I've never had a problem connecting to my home wifi, everything was working fine on Friday, I left the house, went to my girlfriends and my phone connected to her wifi without a problem as usual. I returned home on Saturday and my S5 failed to connect to my wifi, I connected it manually and it connects and disconnects almost instantly. I have 5 other devices including a samsung galaxy note 4 in the house which all work perfectly fine. I've tired switching the router off and on again and that makes no difference, I removed the phone battery for 5 minutes and it then connects to the wifi for about 5-10 seconds then again disconnects, I have no idea what else I can try....
I've tried to forget and then reconnect to the network and that doesn't work either, and my smart switch is off. I have no idea why it's all of a sudden started doing it.
I have exactly the same problem since Sunday, phone won't stay connected even though I have authorised it using the pin system. All other devices including note 2 stay connected to the home wifi, just not my galaxy s5 even though it connects at work etc. Tried resetting home wifi but same problem???