According to Machiavelli, it is better for a ruler to be feared than to be loved. This is the case, he says, because a ruler who is feared is less likely to be overthrown. In other words, Machiavelli is not saying that being feared is good in itself, just that making people fear you is a better tactic than making people love you. Machiavelli argues that this is the case because people will be relatively willing to hurt someone they love if they really have to. By contrast, they will not want to hurt someone they fear because that person might end up getting revenge on them.
This advice is presumably most relevant to autocrats, as opposed to the leaders of democracies. The leaders of democracies need to make themselves loved because there is no way that they can make people fear them enough to keep reelecting them. However, when they are playing "inside politics" it may be useful for them to make others fear them. That is, when a Congressional leader is, for example, interacting with other members of Congress, it may be more useful to make the other members fear him or her so that they will not cross the leader later on.