The latest Xcode version that is documented by Apple to include the iOS 5 SDK is Xcode 4.3.3 for Lion. Apple doesn't document in the release notes whether it is also included in Xcode 4.4 and Xcode 4.4.1. However, by Xcode 4.5 it is definitely not included anymore.
The important thing to notice here is that you actually do not need to have the iOS 5 SDK in order to build an app for iOS 5. This means that you can build apps for iOS 5 with an Xcode that is newer, and doesn't as such include the iOS 5 SDK.
You do this by setting the deployment target of your project. Inside Xcode you click on your project (the blueprint icon), select the Info tab and then you have a drop-down named "iOS Deployment Target". You'll want to set it to 5.1.
With modern Xcode releases, you can download simulators, etc. directly from within the latest Xcode - however this only goes back to iOS 8 for Xcode 10. This also goes for the deployment target.
The end result is that you can use a much newer Xcode than Xcode 4.3, although not the latest Xcode 10 releases. You just need to remember to set your deployment target for the project!