My iPhone 4S currently encountered a software glitch?

The Wi-Fi will not turn on. I never turned it off, it just randomly shut off. Whenever I try to turn it on, it stays grey and won't switch to on. My iPhone is running on software 6.1.3. I have read elsewhere that this version of iOS is glitchy. I have tried everything to fix it, but nothing seems to work. If I take my phone to the Apple store, don't they HAVE to replace it because it's a software glitch?

No, if it persistently happens, they will replace it as long as your device is under warranty. However, they will release iOS 7 really soon. Maybe you might want to consider upgrading to it and see if it solves the problem before replacing it.