I'll approach this from the other way, and recommend which year to stay away from, and that would be the '02, IMO. It's a bit of an oddball in that it was the 1st year, and there are differences in some parts & circuits that aren't found in the '03s forward (this is regardless of engine).
If you want a V8, '04 is the last year before it got cylinder deactivation (that tends to fail)
(this is for the 5.3L; if you find a 6.0L, the LS2 didn't have it)
I6 engines got a few subtle changes over the years, in different areas. IIRC, I think the '06 forward has a wee tiny bit more HP / TQ because of some changes that were made to the head (but would also limit your replacement options, if you ever needed to put a new one on.) Do your homework on this one, as I'm not as familiar with the I6 as I am the V8.
.