Replacing an old used Iphone 5S to a new IPH5S
Yes, this is possible.

However, if you want to keep all your data etc, you will need to do a full backup of your old iPhone (e.g. to iTunes on your Mac/PC) first and then connect the new iPhone to do a restore from the old backup. This assumes, of course, that the new iPhone has at least the same capacity as the old one. If not, you may run into problems.

Also, make sure your friend has followed Apple's advice on What to do before you sell or give away your iPhone, iPad, or iPod touch.