In the novel Blindsight by Peter Watts, vampires have a neurological "glitch" that sends them into an epileptic fit whenever they see a right angle. Presumably the wiring of their visual cortex gives them a very unusual power of perception, but comes with a price. This is called the "crucifix glitch" and the idea is that in nature perfect right angles are very rare, so this glitch wasn't selected against.
I thought this was a brilliant explanation of the crucifix aversion, but you could also utilise it for the invitation problem. After all doors and windows have right angles, so a vampire with a crucifix glitch couldn't pass them with his eyes open. The only way a vampire could enter a house would be, if he was lead by the hand or directed by voice, with his eyes closed (Or possibly with his eyes open, but his vision switched off …).
So basically when our nasty bloodsucker comes into a little village, he has to switch off his vision, right angles everywhere, and proceed by hearing alone. Now he can do this a lot better than a blind human, in fact you wouldn't easily notice that he can't see, but he is still severely handicapped. It wouldn't do to be caught creeping around, touching walls searching for a way in or attacking humans in the open. His only shot at getting a pint of blood, is to be invited into the safety of a house by somebody he can overwhelm even blindly without making much noise.
Enter "the good but foolish virgin/elderly/child" seeing the traveler walking down the middle of the road, looking all forlorn …
So basically the invitation is necessary for two reasons: The vampire needs to hear a voice that leads him through the door without appearing blind (people are incredibly suspicious of the blind in these parts). And people have to let him into the house without making a fuzz, because without his vision he would have a hard time to escape from the horror of right angles that is a village. Only once he is behind closed doors with the "good but foolish" can he strike.
Edit: Did you ever wonder why they build houses like this in the old days? Now you know.