This topic has been exhaustively discussed on this forum, fairly recently, too. Without restating all that has been explained, I'll touch on a few salient points, just for your benefit. First, Sampras actually did win a few clay court events in his career. Second, without any other considerations, a backcourt game is generally going to be more successful on clay than an all court game. But, it's important to understand that in Sampras era, and for the entire history of tennis before that, the different surfaces played very differently requiring completely different approaches to tennis, which gave rise to specialists on various surfaces, especially, clay court specilists, some of whom didn't even play any of the grass court events because grass was a different game than what they played.
Sampras' game was developed specifically to succeed on grass. He was a pure power player who sought to end points as quickly as possible from everywhere on the court. That approach to tennis is rewarded on faster courts, and punished on slower courts that neutralize power and reward patience, especially against clay court specialists who stood back and kept the ball in play almost indefinitely. And Sampras didn't have the benefit of today's oversized racquets and polyester string. Further, unlike today, in the 1980's and 1990's, many if not most of the Europeans were clay court specialists making it very difficult for a fast court power player to get through a field of clay court specialists and win clay court titles.
Federer, by contrast, played/plays in an era of homogenized court surfaces in which the same baseline bashing style of tennis, with oversized racquets and polyester strings, is rewareded on all surfaces. Further, Federer doesn't have to deal with an entire field of clay court specialists like Andres Gomez, Sergi Bruguera, Tomas Muster, Gustavo Kuerten, Alberto Berasategui, Carlos Moya, Albert Costa, Juan Carlos Ferrero, Gaston Gaudio, Guillermo Coria, and that's just a very small sample. And, those last few, who were in their primes before Federer was in his, were the last of the era clay court specialists before all surfaces were made slower. Today, there's only one real clay court specialist, Nadal. So, it should come as no surprise that Federer's ground game would succeed moreso that Sampras' power game on clay in the modern era of homogenized surfaces lacking in any depth of clay court specialists that Sampras had to go through.