There's a way to track your device's history. One is to use the IMEI number. You can look up how to find this number here: https://priorityunlock.com/how-to-find-iphone-imei/. You might find out that the phone was blocked or blacklisted. There are also ways to deal with that. For example, if your phone is from AT&T (like mine) and it was unpaid for a long time, you can read how to unlock an unpaid ATT phone. Spoiler: the most obvious method is to actually contact AT&T and talk to them about the issue. Probably, they would be able to help you even if your problem is not exactly the same as I've described.