The 48-year-old Wisconsin Republican, who pointedly criticized Trump during the 2016 election, said the president's election allowed him to pursue GOP policy priorities. Ryan announced plans last week to retire, months after Congress passed his long-held goal of overhauling the tax system.
"Look at what his election got us. It got us, finally, a unified government," Ryan told CNBC's "Squawk Box." "I'm grateful that he has given us this chance with his election to do fundamental tax reform that is a long time in coming that finally got done."
When Ryan announced his retirement, some reports suggested he no longer wanted to face questions about the president's erratic behavior. In 2016, Ryan slammed candidate Trump for his comments about a Mexican-American judge as well as his remarks about groping women from 2005 that surfaced just before the 2016 election.
Since Trump took office, though, Ryan has largely refrained from any criticism of the president. The House speaker said the president "absolutely" did not influence his decision to leave at the end of his current term. Ryan has said he merely wanted to spend more time with his family.
The GOP is trying to hold on to a House majority in the midterm elections, and Ryan still plans to campaign and raise money for Republicans seeking House seats. He expressed confidence that the GOP will keep control of the House despite enthusiasm on the Democratic side.
Ryan has endorsed House Majority Leader Kevin McCarthy of California to succeed him as House GOP leader, potentially heading off a race between McCarthy and House Majority Whip Steve Scalise for the job.
"I think it should be McCarthy and I think it will be," Ryan told CNBC.
Ryan has stressed that he does not want to step down before January.
Republicans are hoping to keep the House by highlighting the GOP tax law passed in December, the signature Republican achievement during Trump's time in office. However, polling has shown the tax policy has not yet resonated with voters as much as Republicans hope.
"I'm convinced we're going to be able to communicate the benefits of this tax law," Ryan said.