The only way out of a network is through the Default Gateway, and there is no alternative or dynamic way to reroute traffic when the gateway router goes down.
That is where HSRP comes in. It negotiates between two or more routers to elect a virtual router, providing high availability through redundancy.
Given the scenario:

Even with two routers on the same network, each has a different IP address, and half the computers exit through Router1 while the other half exit through Router2 (see the configured Gateway on the PCs). If one router goes down, the other will not pick up its traffic.
With HSRP, all PCs share the same default gateway pointing to a virtual router at 192.168.1.254:
Switch
No configuration at all. All the ports are part of VLAN1.
PC-1
IP Address: 192.168.1.101 Default Gateway: 192.168.1.254
PC-n
IP Address: 192.168.1.1n Default Gateway: 192.168.1.254
PC-24
IP Address: 192.168.1.124 Default Gateway: 192.168.1.254
Router Internet
enable configure terminal hostname Internet no ip domain lookup line con 0 logging synchronous
interface g0/0
ip address 10.0.0.1 255.255.255.252
no shutdown
interface g0/1
ip address 10.0.1.1 255.255.255.252
no shutdown
interface lo0
ip address 8.8.8.8 255.255.255.0
no shutdown
interface lo1
ip address 8.8.4.4 255.255.255.0
no shutdown
router rip
version 2
no auto-summary
network 8.8.8.8
network 8.8.4.4
network 10.0.0.0
network 10.0.1.0
passive-interface lo0
passive-interface lo1
The Loopback interfaces simulate the internet.
Router1
enable configure terminal hostname Router1 no ip domain lookup line con 0 logging synchronous
interface g0/0
ip address 10.0.0.2 255.255.255.252
no shutdown
interface g0/1
ip address 192.168.1.1 255.255.255.0
no shutdown
router rip
version 2
no auto-summary
network 192.168.1.0
network 10.0.0.0
network 10.0.1.0
passive-interface g0/1
Router2
enable configure terminal hostname Router2 no ip domain lookup line con 0 logging synchronous
interface g0/0
ip address 10.0.1.2 255.255.255.252
no shutdown
interface g0/1
ip address 192.168.1.2 255.255.255.0
no shutdown
router rip
version 2
no auto-summary
network 192.168.1.0
network 10.0.0.0
network 10.0.1.0
passive-interface g0/1
Setting up HSRP on Routers 1 and 2:
Router1
interface g0/1 standby version 2 standby 1 ip 192.168.1.254
Optional commands on Router1:
standby 1 priority 150 standby 1 preempt
By default, the priority is 100, and the router with the highest priority becomes the active router for the HSRP group. If there is a tie, the router with the highest IP address wins.
Router2
interface g0/1 standby version 2 standby 1 ip 192.168.1.254
The commands above create standby group 1 on both routers, sharing the same virtual IP. Router1 has a priority of 150 while Router2 uses the default of 100, making Router1 the Active router. The preempt command ensures Router1 reclaims the Active role when it recovers.
The route from the PCs to the Internet can be verified with:
tracert 8.8.8.8
OR
tracert 8.8.4.4
To check the HSRP configuration on each router:
show standby show standby brief
To configure interface tracking, use:
standby 1 track G0/0
This tells the router which interface to monitor.