Beyond the warranty or there’s no apple store close by? Well, nothing more to be said, find the solution and fix it yourself! Moreover, it will most likely have the same issue even if you can get a replacement from the Apple store.
I spent almost an hour to find the solution on the internet, and the result is no exact way to repair the loose button, no matter on iPhone 5S, or other iPhone versions. The only way that has helped part of iPhone users successfully is one answer from apple support community:
The power button you press with your finger, hovers in place over an internal button. The power button is loose so it can move down when you press, the slight space allows minute movement when you shake it.
It didn’t work for me. Yet it is still worth to have a try, after all, someone have benefited from it, so don't give anything away. If you have any ways to solve this problem, please let us know in a comment below, every response will be appreciated!
Furthermore, even you take the iPhone 5S to Genius Bar, what they can do is to replace it, not repair it. Therefore, it is necessary to get Apples attention, if you have encounter loose power button on iPhone 5S, report to Apple here- http://www.apple.com/feedback/iphone.html