It's a convergence of different things, but the main reason, I would say, is that he doesn't give the opponent the necessary rhythm to impose their game. It's not merely tactical, either. His default ground strokes are just hard to deal with. Watching on TV, you could be fooled into thinking that his shots, as offensive as they are, appear flat. In reality, not only are his ground strokes pacy, they are also very heavy. In fact Federer imparts more topspin on the ball than anyone in the top 10 save for Nadal.
Another factor is how much variety he has on his serve. He tends to mix bombs down the T with sliders out wide and the odd body serve, has terrific placement and an unreadable toss. Very little room for the opposition to showcase their strengths.