I don't find the conventional explanation that it was because he kept them out of battle convincing. Sherman and Lee were both hard fighters and popular with their men.
Firstly because he was a talented organizer and had real (if flawed) political skills. Secondly because he was got better results than his predecessors and successors.
The American Civil War was fought by improvised forces, hastily recruited and rapidly expanded from a pitiful pre-war military establishment, and never more so than in McClellan's timeframe of July 1861 to October 1862. McClellan was the person who shaped the Army of the Potomac. He was adept at getting a mass of people who had recently been civilians with no military experience to believe that they were an Army and a competent one. He did this by parades, reviews, improved uniforms, corps badges, giving martial speeches etc. He had a talent for this activity and could play the part of a Napoleonic leader with flair and charisma. Most officers who were promoted outside of their regiments, owed their promotions to McClellan. He also positioned himself in such a way with the troops that he took credit for improvements in their camps, uniforms, provisions etc. while blaming the government for their deficiencies and shortages, of which there were many due to the rapid expansion. As might be expected, this caused considerable friction with his military superior, and the civilian government. But this did not inhibit the creation of his image and cult of personality with the troops.
Furthermore, his record on campaign looks very well in comparison to the result achieved with other commanders.
First Manassas campaign - An unambiguous defeat in which the army was completely routed from the field.
Peninsular Campaign (McClellan) - A campaign in which the Army moved easily by sea instead of difficult marches and then repulsed numerous Confederate counterattacks while inflicting more casualties than they received.
Second Manassas - Another unambiguous defeat in which the army was completely routed from the field.
Maryland Campaign/Antietam (McClellan)- A victory of sorts in which a Confederate invasion was thwarted and an army almost trapped.
Fredricksburg - A failed arduous flanking march under winter conditions followed by brutal and disastrous frontal attacks.
Chancellorsville - Another unambiguous disaster followed by a rout.
Now McClellan's record is certainly full of blunders and open to question because he had numerous advantages he did not fully use. However, to the men of the army that are not privy to the insight of high command, his record looks successful or at least not completely disastrous.
To summarize, McClellan was a talented Military politician (although also severely flawed in his political instincts in some ways) who provided just enough battlefield success that his cult of personality did not collapse in his lifetime, despite historians being highly critical after his death.
/u/petite-acorn draws from Bruce Catton and James McPherson to answer Why were George McClellan's men so loyal? but it may not satisfy you. since the standards were different when the answer was originally written.
EDIT: As noted below, this is an excellent answer for the specific question but does not talk much about the secondary sources. The body text of the OP to me connoted a desire for historiography, since OP may already be familiar with the works currently cited.