In Tanya Chapter 5, this question is discussed. There it's explained that Torah is Chochmas Hashem - Hashem's Wisdom, and therefor learning any Torah is an intense union/connection with Hashem. Understanding His Wisdom is valuable in its own right, regardless of whether it's relevant or not. (See the quote below for more elaboration).
דרך משל: כשאדם מבין ומשיג איזו הלכה במשנה או בגמרא לאשורה על בוריה
When, for example, one understands and comprehends a particular halachah in the Mishnah or Gemara, clearly and thoroughly, through strenuous application of his mind,
הרי שכלו תופס ומקיף אותה, וגם שכלו מלובש בה באותה שעה
his intellect grasps and encompasses that halachah, and his intellect is also clothed in it at that time when he strives to understand it.
והנה הלכה זו היא חכמתו ורצונו של הקדוש ברוך הוא
Now, this halachah is the wisdom and Will of G-d — the rationale underlying the halachah is G-d’s wisdom, and the ruling itself is G-d’s Will, as mentioned in ch. 4.
שעלה ברצונו שכשיטעון ראובן כך וכך, דרך משל, ושמעון כך וכך, יהיה הפסק ביניהם כך וכך
It so arose in His Will that if, for example, Reuven would claim thus and Shimon thus, such and such should be the verdict between them.
ואף אם לא היה ולא יהיה הדבר הזה לעולם, לבא למשפט על טענות ותביעות אלו
Even if it never did nor ever will come to pass that litigation occur over these arguments and claims,
Thus, were the purpose of Torah study only to learn how to practice its laws — in this case: how to resolve this dispute — then the study of such a law would indeed serve no purpose. In fact, however, there is great value in studying even such a halachah, for thereby one knows G-d’s Will and wisdom, and attaches himself to it, as the Alter Rebbe continues:
מכל מקום, מאחר שכך עלה ברצונו וחכמתו של הקדוש ברוך הוא, שאם יטעון זה כך וזה כך יהיה הפסק כך
yet, since it arose thus in G-d’s Will and wisdom that if one person would claim this way and the other that way, the verdict be such and such,
הרי כשאדם יודע ומשיג בשכלו פסק זה, כהלכה הערוכה במשנה או גמרא או פוסקים
therefore when one knows and comprehends this verdict as a halachah set forth in the Mishnah or Gemara or Poskim (the halachic codifiers),
If one arrives at the identical verdict on the basis of any other legal system, this verdict represents human knowledge, not Divine wisdom. If, however, he derives the ruling from Torah,
הרי זה משיג ותופס ומקיף בשכלו רצונו וחכמתו של הקדוש ברוך הוא, דלית מחשבה תפיסא ביה ולא ברצונו וחכמתו
he then actually comprehends and grasps the Will and wisdom of G-d, Whom no thought can grasp, nor [can any thought grasp] His Will and wisdom,
כי אם בהתלבשותם בהלכות הערוכות לפנינו
except when they — G-d’s Will and wisdom — clothe themselves in the halachot set before us.
This is one facet of understanding Torah, namely, that thereby one’s intellect encompasses the Divine Will and wisdom.
...
והוא יחוד נפלא, שאין יחוד כמוהו ולא כערכו נמצא כלל בגשמיות
Now this is a most wonderful unity; in the physical realm there in no unity similar or parallel to it, i.e., of two things as disproportionate as human intellect and Torah, G-d’s intellect —
להיות לאחדים ומיוחדים ממש מכל צד ופנה
that they should actually become one and united from every side and angle.
וזאת מעלה יתירה גדולה ונפלאה לאין קץ, אשר במצות ידיעת התורה והשגתה
This is the distinctive, infinitely great and wonderful superiority of the mitzvah of knowing and comprehending Torah
על כל המצות מעשיות, ואפילו על מצות התלויות בדבור, ואפילו על מצות תלמוד תורה שבדיבור
over all the mitzvot involving action, and even over those performed through speech; indeed, even over the mitzvah of oral Torah study.