Get the newest quality house you can afford so maintenance will be cheaper. Thing is, if you plan to be in that house for another 20-50 years, that same maintenance might come up by that time just as you can't afford it all as you hit retirement. It might be a wiser idea to buy a house every 10-20 years to keep ahead of having to do "aging" maintenance on roofs, foundations, HVAC, plumbing, electrical, chimney, paved or concrete driveway, skylights, septic and well if not city provided, windows, wall insulation, converion to aluminum siding someday, etc. You could easily spend 50% of the original cost of the home to essentially rebuild/replace/update everything at the 40-60 year point. Get into a nice 30 year old home to only have deal with constant repairs 20-25 years later.
Aging trees can be an issue, especially maples and oaks. A healthy 50-60 oak tree today can be a problem once it hits 75-85 years old. If you have lots of middle-aged trees around your house figure $1K-$3K to take each one down. I've done 6 so far to over $10,000.
I hate skylights. Figure they will eventually leak and cost $1K each over the years. Same comment for windows that just out from the house, more likely to leak.
Avoid homes with excessive white efflourescence/spalling/flaking on the foundation walls and the garage floor. While some might be normal over 30-50 years, it's a sign of water migration. And over time it weakens the walls and require you to resurface you garage floor. If you buy a home with good drainage, say sitting up on a hill, your water migration odds are reduced. If you're near the shore, a small brook, or close to a lake be very leery of this as a higher water table tends to stay for weeks or months at a time. If the foundation area was never properly prepped for drainage it might not even matter where the house is, water can get into the basement over time. Looks for signs of water migration.
Check the attic for signs of water entry/staining on the beams and chimney. Look for signs of mold in the bathroom shower or high up in the closet corners. A poorly insulated attic can allow moisture into the outer upper walls.
There is an advantage to a 30 year old house in that you can see how the foundation has held up. But other than that, the drawbacks are numerous. Do turn on the burner, AC, water pump and whatever heavy loads are available to ensure the lights don't dim as the loads are cycled. I'd be leery of additions (garage, porch, extra rooms) that were added on years layer by cheap contractors. Those tie in points are sources for water and bugs if they weren't properly done.
For an older house, you need to know the age of every system and when you'll be replacing it down the road. If your water has a pH of 6 or under, expect slow deterioration of your pipes, burner, and water heater over time. City water should have an adequate 7-8 pH. Green sulfate on copper pipes in an early sign of attack. Run the water pump and tank through a cycle. Make sure you get the stated capacity out of it before the pump kicks on again (4-20 gallons depending on tank size). If you're cycling on only 1-2 gallons that's a problem. Check the sinks for any seeping water, especially with staining on the wood underneath or in the basement below.
When my son and buddies did my roof in 2009 they were dropping pallets of shingles from their shoulders on to the roof. I didn't notice to a few years later than they cracked a number of beams in the attic. If you have gutters, makes sure they flow properly and don't have dams or moss and organics building up in them annually. Corners of gutters are prone to leakage especially when not hung right. Feel free checking them out to flow a few gallons to ensure nothing pools up. That will cost you hours of annual maintenance every year...or spend another $1K or more to rehang them all properly.
A lot of home inspectors will blow off a lot of these details as normal wear and tear. While they don't work for the realtors, they also want repeat recommendations from them. Get a 10 year old house and plan to be out by 30 years. Then downside into your "fresh" retirement home. I hired my own independent home imspector and he went along with the 3 layers of shingles on the roof. In fact, that roof was already leaking, though we didn't find out until 2009 when base wood had to be replaced in many areas. If a shingled house, find one with a single set. The double set is more than half-way to replacement.
I'd prefer to find a home with a chimney that was already modified to a wood stove and stainless steel metal flue ($1500-$2,00). You want some sort of winter back up if you lose all power. And an old drafty chimney is not very efficient. Ideally, one in the basement too to keep pipes from freezing if you live up north.
My house was built in 1960. The repairs started right around 1998 when the burner failed. Then came water pump, burner again in 2008 (2/3 under warranty), full new roof in 2009, concrete repairs in 2013-2014, 30+ yr old driveway is shot but I'm limping that through, copper piping on its last legs which means ripping out all the heaters and pipes soon, chimney being patched yearly but on its last legs, a porch foundation that needs to be replaced, garage floor needs resurfacing, electrical is under-sized at 100 amps, need to update kitchen and bathroom. 5 more trees to cut down ($10K). And the list goes on.