The 39-year-old Federer became the oldest man to reach the third round at Wimbledon in 46 years, winning every service game to earn his 11th consecutive victory over Gasquet. Ken Rosewall was 40 years old when he reached the fourth round in 1975.
"I was really happy with my performance," said Federer, who improved to 19-2 against Gasquet.
Federer is attempting to win his ninth Wimbledon title and his 21st major championship, which would shatter the men's record he shares with Spain's Rafael Nadal.
Elsewhere in the men's draw, No. 2 seed Daniil Medvedev, No. 4 Alexander Zverev and No. 7 Matteo Berrettini all won their second-round matches Thursday.
Top-seeded Novak Djokovic's bid for a sixth title continues Friday after he won Wednesday.
On the women's side at Wimbledon, top-seeded Ashleigh Barty defeated Anna Blinkova in straight sets Thursday to advance to the third round. Rising American star Cori "Coco" Gauff beat Elena Vesnina 6-4, 6-3 to reach the third round.
Meanwhile, Madga Linette earned an upset victory over No. 3 seed Elina Svitolina in straight sets, while unseeded American Shelby Rogers upended No. 15 Maria Sakkari 7-5, 6-4.