According to Starling Talk, the average life expectancy of a sparrow in captivity is 12-14 years, although the longest recorded lifespan is 23 years. There are many factors that contribute to how long a sparrow lives.
The average life expectancy of a wild sparrow is almost always under 10 years, and usually closer to 4-5 years. Because they often live near humans, a lack of natural predators contributes to their relatively long lifespan.
A captive sparrow usually lives longer than a wild one because they have consistent access to food, water and shelter. Wild sparrows must overcome natural obstacles that often cause their lives to end prematurely.