In a speech in Nairobi, he said his father's homeland had "come so far in just my lifetime".
But he also said corruption, terrorism and tribal or ethnic division were threats to its future.
"Kenya is at a crossroads, a moment filled with peril but enormous promise," he said.
Young Kenyans nowadays did not have to serve a colonial master or leave the country - like his grandfather and father had had to, Mr Obama said.
"Because of Kenya's progress, because of your potential, you can build your future right here, right now," he said to applause from a huge audience at a sports stadium in the capital, Nairobi.
But he warned that despite the country's political stability, tribal and ethnic divisions could be stirred up.
"A politics that's based on only tribe and ethnicity is doomed to tear a country apart. It is a failure - a failure of imagination," he said.
However, he praised the country for emerging from the ethnic violence that erupted after the disputed 2007 election.
President Obama also warned that the "cancer" of corruption was costing the country 250,000 jobs.
And he condemned the repression of women - including female genital mutilation and forced marriage, which he said did not belong in the 21st Century - adding that the best use of development aid was to spend it on girls' education.
He also urged Kenya to "embrace diversity", a clear reference to gay rights.
Security has been tight for Mr Obama's two-day visit to Kenya.
The trip, which began on Friday, is his first visit as president to the land where his father was born.
Mr Obama has now flown to Ethiopia, the first US president to visit the country. He will also become the first US leader to address the 54-member African Union (AU) on Tuesday.
AU Commission chief Nkosazana Dlamini-Zuma described the trip to Ethiopia as a "historic visit" that would "broaden and deepen the relationship between the AU and the US".
On Saturday, Mr Obama praised Africa's economic and business potential in a speech at a business summit.
He also visited a memorial for those killed in the 1998 US embassy bombing in Nairobi.
After holding bilateral talks, President Obama and President Kenyatta said they were "united against terrorism".
But they differed sharply in their positions on gay rights. While Mr Obama spoke strongly against discrimination, Mr Kenyatta said Kenya did not share the same values.
US President Barack Obama has praised Kenya's economic and political advances, but also warned of challenges ahead.