It is dangerous to keep bad company even if that is only one person because that rotten one can have a very bad influence on the rest for the friends. The proverb teaches prudence in keeping company with people that have vices since those can be contagious and catch the rest of the group the same way that bacteria from one rotten apple catches the other apples near it.