Blackadder is an interesting case in point. In the first series, Baldrick is the intelligent one, whilst Blackadder is the fool; for the rest of the show it's entirely the opposite way around.
I think that the difference between a sidekick and a companion is in how the main character perceives them. A sidekick is often treated (rightly or wrongly) as inferior - sometimes physically, usually mentally. Any suggestion that the sidekick comes up with is usually dismissed as foolhardy. A companion is respected by the character, and treated as an equal, or at least worthy of consideration.
The lines can be blurred though.
Is Rodney Trotter a sidekick (when he and Del dress up, guess who is Batman).
Is Samwise Gamgee a sidekick? Frodo treats him so; having affection for someone isn't the same as having respect for their views and opinions.
Is Stan Laurel a sidekick to Oliver Hardy?