When your regular internet connection fails, you can go online with your iPhone as "personal hotspot": it transforms your 3G / 4G / LTE cell signal into a Wi-Fi hotspot, which appears under available networks like a wireless router does at home or the office, or a public network at a coffee shop, school, public library, etc. It may not be as fast as your normal connection, but it's a great backup solution! Note: keep in mind that this traffic counts towards your data usage.
Once on your home screen, tap on the gear icon to launch the Settings app. Now tap on Personal Hotspot, which is the last option in the first group.
Tip: while in settings, you may want to enable low-power mode. When serving as a hotspot, your iPhone will use more power, since it's always working!
On the next screen, tap on the Personal Hotspot switch toggle to enable the feature, if needed. Next, tap on the Wi-Fi Password button to set or change it. Apple will have generated one for you by default. Pick hard enough to guess, but easy enough that you'll remember it without having to look at your phone!
Tap on Done (top right). Your iPhone is now broadcasting its SSID (network identifier), like a regular router. Go to your Mac or PC and connect like you would to a normal wireless network. It should be the same name you see when you manage your iPhone in iTunes. As you can tell from the screenshot, some characters may become weird looking symbols. Note: Macs and iOS devices with the same iCloud account / Apple ID will automatically detect the hotspot.
Once you start using your iPhone's connection, a blue bar will appear at the top of your screen (at least if you've upgraded to iOS 9), showing something like "Personal Hotspot: 1 Connection". Enjoy your connection, but remember about data caps, overage fees, and other limitations or financial penalties your cell phone carrier or plan might have associated with any extra data usage!