Royal dukedoms are personal gifts of the British monarch, and traditionally assigned to family members. The titles are not necessarily passed on to the holder's offspring; they may become vacant when the holder dies or accedes to a more senior title.
Some titles, such as Duke of Cambridge, are almost entirely honorific.
Others come with significant lands and revenues. Prince Charles is Duke of Cornwall; this title comes with 570 km^2 of land, generating an income of £19 million per annum. When the title is vacant, this revenue is collected by the monarch.
Having the lands and responsibilities of a dukedom is considered a mark of adulthood. In times past, it would have helped train the holder for other royal duties and perhaps eventually becoming King; and hopefully ensured that the reigning monarch had a reliable manager for a portion of the royal lands. The custom of awarding dukedoms to younger royals is to some extent a relic of this practice.
Prior to House of Lords reform in 1999, a royal dukedom entitled the holder to a seat in the upper house of the British Parliament, although in modern times members of the royal family seldom voted or attended debates. After the 1999 reforms, royal dukes no longer have seats in the Lords.
Finally, the awarding of titles can symbolise the commitment of the royal family to all parts of the UK. The Duke of Cambridge was until recently a pilot at an air rescue service based in Cambridge; the Duke of Edinburgh has maintained some other ties to the city, for instance serving for many years as Chancellor of Edinburgh University.