Why do these teams play? Notre Dame owes a debt of gratitude to the Navy. In the 1940s, because of WW II and the draft, Notre Dame almost had to close due to lack of students. Remember that ND was not coed in the 1940s. On the other hand, the US Naval Academy needed room for more students. ND and Navy struck a deal where Navy would send students to Notre Dame. Without that deal, Notre Dame might have had to close.
Notre Dame coach Frank Leahy also served in the Navy during the 1940s. Conventional wisdom is that he spent his tenure there recruiting, and when he returned he built a dynasty winning national championships in 1946, 1947, and 1949.
So hat’s off to the Midshipmen. Notre Dame will always owe Navy a debt of gratitude.