How can I upgrade my iPhone from iOS 4.1 to iOS 5.1?
Update the iOS software on your iPhone, iPad, and iPod touch
How To: Update To iOS 5.1.1 On iPhone 4/3GS While Preserving Baseband With Sn0wBreeze [Windows]
Which model of iPhone do you have?
If you have an iPhone 3G the highest supported iOS version is 4.2.1. You will not be able to restore a newer version on this model.
We need more information to know for sure, but if your phone won't update by going to Settings > General > Software Update, then your device is probably too old to update to iOS 5. This means your device is running an archaic operating system and I would recommend getting a new phone as soon as possible.