The actual answer depends largely on the genre. In some genres a villain is simply an active impediment between the hero and his goals, e.g. conservative father vs. daydreaming son. In other genres the rivalry assumes larger proportions, with the villain commanding armies of minions, and the hero having the face them, e.g. a large number of superhero plots.
In any event,
Make your villain more heroic than the hero.
If you want the reader to believe that the villain is on the side of the hero, give them a moral stature that is far superior to the hero himself. Throughout the story the villain could:
- stop the hero and impose a stricter moral code to their actions;
- scold the hero for not following a higher moral standard;
- be regarded as an inspiration by the hero for their higher moral stature.
This is strongest when the villain truly has such moral qualities, instead of just pretending. To show it, you may need either minor villains with lower moral standards, or very long dialogues between the hero and the sidekick villain.
You mentioned Spiderman. Take Batman, who abides by the moral code of not killing: his villain sidekick will abide by a stricter moral code of not even physically harming anyone. For instance, he could defeat the minor villains with psychological means, or by checkmating them in a long strategic game, or simply reverting/nullifying the negative part of their deeds.
True or Fake? The decision is yours
It is up to you whether the sidekick villain truly has a higher moral code compared to the hero, while their ultimate goals are not in line with what we consider good (paperclip villain). On the other hand, it could all be just a ruse of the sidekick villain to toy with the mind of the hero, make them believe that there truly is a higher moral code, and render them impotent when faced with a real threat (Truman Show villain).
A word against evil-doing sidekick villains
Finally, I'd argue against making your sidekick villain look like a rough-but-good sidekick. First, it is difficult not to alert the reader with every odd action by the sidekick. Second, it has a negative impact on the hero during the reveal: a good and intelligent hero would unlikely accept such a company and would not once suspect that the misbehaving companion could be a villain all along. Third, it has a negative impact on the re-reading value of the story, when all the evil actions of the sidekick lose the benefit of the doubt, and just become vulgar criminal acts, which simply go unpunished for a good part of the story, with good grief for the fans of your now shortsighted hero.