In some scenes in Avengers: Age of Ultron Iron man, War Machine, and Captain America try to lift Thor’s hammer but they end up failing. At some point Vision lifts it easily. How can Vision lift it?
Because he's worthy of it.
The fact that the Vision can lift the hammer, in contrast to all the other heroes (apart from Thor, of course) is an important clue to convey the Vision's actual spiritual purity and superiority. Remember that the Vision was created in a collaborative process by the Avengers, taking Tony's benevolent AI J.A.R.V.I.S, putting it into the pure mind gem (now cleaned of whatever evil spirit was in it that's now in Ultron), putting that into a perfect Vibranium-enhanced body and putting it to life by Thor's very powers.
To me the Vision seems to be the embodiment of the ancient ideal of a perfect mind in a perfect body, one that combines the advantages of a mechanical intelligence with the concerns and soul of an organic lifeform and brings compassion for his (undoubtedly inferior) human fellows, in contrast to his much less modest and unidentifiedly-spirited brother Ultron. He thus seems to be the ideal creation of a humanity that strives for posthuman evolution. One could say in his second try Tony Stark (with the help of an actual (demi)god and some magic alien artifacts, though) overcame his role as merely a "Modern Prometheus" and didn't just create sentient life, but a new god in itself.
And the fact that Vision is able to wield Mjölnir to me doesn't come from the fact that he is "just a machine", as Tony and Steve argue jokingly at the end, but from the fact that he is superior to us all not only in his body but even more so in his mind. And this I think is the attitude that Mjölnir is attracted to, as already shown in the first Thor movie and also in this one when Steve nearly achieves to lift it (which was not because he is the strongest, but because he is the noblest at heart). In fact, Tony's and Steve's theories about Vision being "only a machine" at the end even support the interpretation that this is not the case by the mere humorous way they are presented in. Of course their childish excuses are not the reason for why The Vision achieved what they couldn't. In fact his pickung up the hammer is a perfect and to the point illustration of Vision's superiority and immediately clarifies that to the viewers, a symbol that has been explicitly set up by the earlier scene (with the whole gang trying to pick up the hammer) for exactly that purpose. Or as the apparent expert on the intricacies of Mjölnir has to admit himself at the end:
Thor: He can wield the hammer, he can keep the Mind Stone. It's safe with the Vision and these days safe is in short supply.
And you wouldn't want to keep the Mind Stone lying around in an elevator. So yes, Vision does get the power of Mjölnir and Thor with everything connected, including the abstract notion of "being worthy". But what makes Vision so extraordinary as part of his "worthiness" and what makes it seem as if he doesn't get that power (i.e. without the nice special effects described in Dr R Dizzle's answer) is that he doesn't want it anyway. He doesn't strive for this power and he doesn't care to rule over Asgard, not because he can't as "a machine" or because he doesn't have a soul, but because his mind and motivations are above such "worldly" considerations. His light-handed and downplayed way to hand over the hammer to Thor and his easy ability to carry it in battle convey both his worthiness and his not caring about this at all. He is a god without a god-complex.
The inscription on Mjolnir reads;
"Whosoever holds this hammer, if he be worthy, shall possess the power of Thor."
We know from Thor, The Avengers, Thor: The Dark World and Avengers: Age of Ultron that only those judged worthy can lift Mjolnir. When judged worthy, the hammer gives the lifter the power of Thor. I elaborate on this in this answer, but the short of it is that those worthy of Mjolnir can not only lift Mjolnir, but they are also granted power by it.
Importantly, when we do see The Vision use Mjolnir rather than simply holding it (when he hits Ultron with it), we see that he hits no harder when 'wielding' Mjolnir than he would have anyway. The Vision is not granted the power of Thor, as the inscription on Mjolnir would suggest. This means that Mjolnir does not judge The Vision worthy, and as such can only be lifted by The Vision because he is not counted as a person from Mjolnir's perspective.
Additionally, when we see Thor regain his worthiness in Thor, his lifting of Mjolnir is accompanied by various special effects indicating him being 'powered up', none of which are present when The Vision lifts Mjolnir - because he isn't worthy, and has not been granted the power of Thor.
This means that when Tony and Steve are trying to comfort Thor at the end of Avengers: Age of Ultron, they are in fact correct - The Vision lifting Mjolnir makes him no more worthy than an elevator lifting it would, or as the Helicarrier in The Avengers or a coat hanger in Thor: The Dark World does.
In short, The Vision can only lift Mjolnir because his status as an android would seem to make him exempt from the rules.
So far people have surmised that either...
A) The Vision's status as an android exploits a loophole in the rules regarding the wielding of Mjolnir, as set by Odin, because The Vision, as an artificial intelligence encased in a android body, isn't actually a person, but a machine.
B) that The Vision, being newly created and therefore not yet physically, mentally, spiritually, emotionally or morally compromised/corrupted in any way, and with him having been created by downloading Jarvis' benevolent artificial intelligence into an android brain/neural network designed by Ultron and powered by the Mind Stone, and that The Vision is therefore "worthy" of wielding Mjolnir.
I'd like to point out a couple of flaws in those theories...
As for the first theory, that The Vision isn't a person and can therefore lift Mjolnir in the same way as any elevator or heli-carrier or Quin-Jet would, it should be pointed out that The Vision didn't just lift the hammer - he threw it, caught it, flipped it, hit Ultron with it, etc. He, in effect, "wielded it". It should also be noted that Odin wouldn't be at all unfamiliar with androids or artificial intelligence - but I don't believe The Destroyer can lift Mjolnir either.
As for the second theory, that Mjolnir considers The Vision to be worthy of wielding it (and ruling Asgard too - let's not forget that!), I would point out that there was no "power-up" when The Vision first picked up the hammer. He didn't suddenly gain armored sleeves, a cape, an ornate helmet, etc., such as what happened when Thor became "worthy" in the first Thor film, or such as what happened when Jane Foster became the new Thor. And, while The Vision did wield Mjolnir in the battle with Ultron, he wielded it in the hitting/throwing sense of the word, but he didn't appear to have mastery over thunder and lightning like Thor does.
If I may offer an alternative theory, it would be that the source of The Vision's power, the Mind Stone, is one of the five "Infinity Stones", and is therefore an ancient and mystical object of immense power.... Power that is far older and stronger than any spell/curse that Odin could possibly cast on Mjolnir (or any other object). In short, the Mind Stone's power was unaffected by Odin's rules or even the powers granted to the person/people worthy of wielding the hammer. The Vision, as the embodiment of the Mind Stone is simply too full of ancient power to be subject to mystical limits placed on objects by Odin, who, to The Vision, would be an inferior being. Basically, that becoming the new Thor would be something of a demotion for The Vision.
Lastly, as a side note, to address the comments of those people who mentioned various instances when Captain America, Hulk and others wielded Thor's hammer, I would point out that each such instance happened in the comic books during a period of time in which Odin had taken Mjolnir away from Thor as punishment for Thor's defiance in not leaving Earth and returning to Asgard, as Odin had ordered. Following Thor's being stripped of Mjolnir, Tony Stark created a new hammer for Thor (actually, a hammer on one side and an axe on the other). The new hammer was as close as Stark could get to the actual Mjolnir as earthly physics and cutting-edge earthly technology would allow. But the new hammer did have it's limitations, and the whole "worthiness" thing was one of the major limits, as pretty much anyone with enhanced strength could lift it.
This is actually an open question even at the end of the movie. Tony, Steve, and Thor are debating this exact question in the final scene.
There are two possibilities they raise.
First, the easiest answer is, Odin's enchantment found him worthy. If you note, Rogers almost managed to pick up Mjolnir, implying that he is almost worthy, but not quite. Vision, for whatever reason, is considered as worthy as Thor to wield the hammer. Thor tends to believe this is true, which is why he let Vision keep the Infinity Stone. It's possible that is the other way around: because Vision is holding the Stone, that makes him worthy.
The other option is that Vision doesn't count as a "person", since he's an android (meaning, he basically exploited a loophole in the magic). As Rogers surmises, this is no different to putting the hammer in an elevator: the machine would "lift" Mjolnir but he isn't really "wielding" it.
In the comics, there have been several others besides Thor to wield the hammer over the decades, including Cap, so this would have been an unusual and significant event, but not unheard of. It remains to be seen in the MCU if things work out the same.
It was probably a good way to fast prove to the spectator that Vision is an ally. It can also be that Vision was born because of Thor's thunder. Or maybe it's because Vision is just born and he is absolutely pure.
I know this is a slightly old question, but- I've decided that Vision can only pick up the hammer because technically, he's an inanimate object. He's not exactly a human who can be worthy of Mjolnir, so I hint it's kinda the same as when Thor hangs the hammer on a coat rack in one of the Thor movies, I forgot which one.
He's not worthy of the hammer. The reason why he picked it up is because of Thor's hammer, which helped bring Vision to life. Technically, a BIT of Thors powers are in Vision.