Or is it just a fun coincidence? In school, I was taught that the Shia Muslims cared about primogeniture and inheritance from the prophet, but the Sunni Muslims didn't think it mattered.
The Shia/Sunni divide was mainly a debate about who should lead the faithful after Muhammad's death (which then lead to further splits on mainly judicial and interpretive issues).
So while the Sunni do not believe that the leader of the faithful must be a descendant of Muhammad, his family does still have a special status in Islam, it's an issue of prestige. The Royal family of Jordan doesn't use it to justify their rulership over Jordan or the Islamic religion, it's a just an aspect of prestige which they use to their advantage to gain respect.
"the Sunni Muslims didn't think it mattered"
That's not entirely true. The house of the prophet was and is still revered and respected even if the descendants of Ali (who were direct descendants of Muhammad through Fatima) have a particularly special place in Shia Islam. See, for instance, these enormous calligraphic medallions of Hassan and Hussein in the Hagia Sophia in Istanbul: LINK (NB: There are of course other reasons why a huge empire, even a Sunni one, might want to include these names, not least when they counted so many Shia as subjects, but the point on respect of the House of the Prophet stands.)
Descent from the house of the prophet has also traditionally been accompanied by honorifics in Sunni Islam, namely the terms Sayyid and Sharif, which could be translated as "Sir/Lord" and "Honorable/Noble" respectively.
Inheritance law (like primogeniture) is a good analogy for the dispute over the early succession to the Prophet but doesn't really capture the entire issue, not least because primogeniture was not a custom or tradition in pre-Islamic Arabia and was not established as such by Muhammad etc. etc. Rather, the custom, and this is attested to in the later Hadith, was succession through the tribe. So the kinship relationship is critical, but lineal descent is less important.
As I mentioned this is perhaps most famously reflected in the "Hadith of the Twelve Successors" in Sahih Muslim (and others) where Muhammad says that all of his twelve successors will be from Quraysh. This is a well-attested Sunni Hadith, although the extent to which its been kept is in dispute. The Ottoman Caliphs were certainly not "of Quraysh", though various Islamist movements that have sought to reestablish a Caliphate in contemporary times do hold that as a critical qualifying criterion.
So that's the place of the house of the prophet in Sunnism generally, so how about the Hashemite dynasty in particular?
Remember that though they are now Kings of Jordan, the Hashemites' original position was as the Sherif's of Mecca which included rulership of most the Hejaz. Hashemite rule of this province goes back centuries, although not necessarily as a formalized position. Here the terminology gets a bit confusing, because the Abbasid dynasty were "Hashemites" insofar as they were part of the Banu Hashim, the descendants of Muhammad's great grandfather Hashim.
To say that "the Hashemites were the Sharifs or Emirs of Mecca" is therefore a little weird, because all that really means is that the most prominent clan of the most prominent tribe in a city in which that tribe had maintained power still maintained power. Nor was this position of Sharif or Emir strictly lineal. In the Ottoman period it was not uncommon for the Emirs to step in and put some cousin or uncle or other Hashemite into the position, but being of the clan of Banu Hashem, with direct descent from Muhammad, was still the main qualifier which lent both tribal authority for peoples living there (as it had always done) as well as a claim that by their descent they were uniquely qualified to be guardians of Mecca and Medina rather than some other group of leaders.
The modern Jordanian Hashemite dynasty, as "the Hashemites" is quite a late development. The current king's great-great grandfather Hussein was appointed Emir of Mecca late in life following a complicated period in which a series of cousins and uncles were appointed to the Emirate by the Ottomans. At the last minute, a distant cousin was likewise considered for the position before the Ottomans settled on Hussein.
Following the Arab revolt, Hussein's eldest son Ali was set to inherit the Hejaz, his second son Abdullah was made king of Transjordan, and Faisal was given Iraq.
Hussein himself would claim the Caliphate after it was abolished by Ataturk, however the Saudi conquest of the Hejaz, Hussein's deposition and the decision of his sons not to press for the title of Caliph scuttled that. Nonetheless, to circle back, his claim to the Caliphate, his religious leadership of Islam during the Arab revolt, these were all in part predicated on his spiritual position as a descendant of Muhammad in addition to his more straightforward tribal power base.
It's these descendants of Abdullah who are the ruling Hashemites to this day.
Unfortunately I can't speak to how much this descent from the prophet has been used in 20th century Jordanian legitimation or politics by current ruling family. Other than the official name of Jordan being "the Hashemite Kingdom of Jordan" I think the basic answer is not very much. Not to break the 20 year rule, but it's not a feature that I see brought up very often in contemporary Jordanian politics, in contrast with, say, the centrality of the Saudi claim of being "Protectors of the Two Holy Places" (i.e. Mecca and Medina).
edit: great-great grandfather, not great-grandfather, I forgot about Talal ibn Abdullah for a second!