When we read the ten commandments, It would appear that the first commandment would make the second commandment unnecessary. However, God knows the nature of men and their tendency toward idolatry, and therefore included the second commandment because of this tendency.
