If you received this phone as a gift, then the person that purchased it will know where it came from. It sounds as if the phone you have is locked to a particular carrier, and the SIM you are trying to use is not from that carrier.
If you cannot find where it was purchased and who it may be locked to, you may want to make an appointment at the Genius Bar at Apple to see if they can tell you who it is locked to. At that point, you will only be able to use it with that carrier. A phone being locked is not a warranty issue, so a replacement phone would not be an option. Also, if this phone was purchased outside of the US, then the warranty is only valid in that country of purchase. I suggest a long talk with the person that gifted you the phone to find out what and where they purchased it.