Yogyakarta's founding and importance arises from a dispute in 1755 between the susuhunan (king) of Surakarta (Solo) and his brother about cooperating with the Dutch colonial government, among other things. The then Prince Mangkubumi left Solo in a huff and returned to Yogyakarta to build the kraton. He took the title of sultan, and his descendants rule Yogyakarta, albeit ceremonially, to this day.
Yogyakarta's prominence in the present day may also be due in part to the role supposedly played by the city and its sultans in the expulsion of the Dutch. In fact, if you visit the kraton, you'll be shown the desk where the plans for the revolution where drawn up. At least, that's their story and they're sticking with it.