I've been fighting the same thing for a couple months - Just figured it out.
(Besides replacing Hub Vacuum and checking the lines for holes)
Part needed was.... 2004-2011 Ford F-150 F 150 4x4 Hub Lock Actuator IWE
What had happened was water was getting sucked into the system by the hub vacuum, which is brilliantly located by the firewall of the truck - directly UNDER WHERE ALL THE WATER RUNS OFF THE WINDSHEILD! Really!
So over time water had got into the Actuator and displaced it enough that the shaft wouldn't go into the hub straight. Hence the horrible teeth grinding noise. Also explains when on cold days it was worse because the water in the actuator would freeze and compound the problem, and when I would back up it would reset it self - and when i would then drive forward it would try to engage because of the displacement of the actuator!
Hope this helps, it was very frustrating process.