Why is the maximum endurance for a piston aircraft at sea level?
Try working it from the other end. A propeller needs to generate a certain amount of thrust to maintain a given indicated airspeed to fly.
In thinner air, it must turn faster to do so.
Turning faster is higher RPMs.  Higher RPMs mean more engine friction.
More fuel must be burned per unit time to overcome engine friction at higher RPMs.
RPMs to generate a given amount of thrust are lowest at sea level
(maybe lower in Death Valley (on a colder day)).
Because the horsepower requirement for maximum endurance speed is much lower than the maximum rated output, the horsepower loss due to thinner air is not an issue until one is higher up.  This is why &quot;leaning&quot; is required at higher altitudes.
But &quot;air density&quot; is the correct answer.