The president, who has skipped the event throughout his presidency, said he accepted the invitation after being asked “very nicely.”