TLDR summary; two views basically, both claimed to be realist:
it was a mistake according to Morgenthau, Kennan etc. Korea not a "core interest" basically. Realists never claim all countries act according to realism, but admit temporary ideological follies are possible.
it wasn't a mistake because the goal was to diminish the prestige and credibility of the Communist camp by showing they couldn't easily take a province in their near abroad. E.g. Benjamin Miller or Jeffrey W. Taliaferro. Actually the latter's theory is more descriptive than prescriptive, since it includes loss aversion borrowed form prospect theory, as a factor, so has a "mistake factor" added, essentially.
Depends whom is your favorite realist, I suppose. Since there's already an answer from the Morgenthau perspective... I'll only say about that one thing to keep in mind is that, generally speaking, no realist claims their theory is always followed. E.g.
Mearsheimer acknowledges that “omitted factors” such as ideology “occasionally dominate a state’s decision-making process” and explains that these exceptions merely demonstrate that there’s a “price to pay for simplifying reality” into theory.
Thus you can have those like Morgenthau who don't explain it through their theory proper, but merely as (random?) deviation from it, as a mistake, ideological folly, etc.
I did manage to find one book chapter by Israeli professor Benjamin Miller claiming that the US deploying to Korea in the 1950, was not a folly or mistake, but precisely what offensive realism demanded them to do. Here's a quote:
Contrary to Mearsheimer, Layne, and Dueck, we argue that US strategy
changed twice in the first formative years of the Cold War. In 1945– 46, the US
followed a liberal strategy (albeit defensive rather than offensive), but in the
1947– 50 period it switched to a more hard- line defensive realist one. Then,
following the North Korean attack on South Korea in 1950, its grand strategy
changed once more—this time to an offensive realist one. None of the three
studies discussed above captures these variations because they all regard US
grand strategy in this period as constant and unchanging.
In addition, in contrast to Layne’s and Dueck’s interpretation, we argue
that the main causes for the adoption of these various strategies were not domestic
or ideological, but rather external, more specifically, the realization of
the military might of the Soviet Union (its control of Eastern Europe and its
ability to occupy the rest of Europe) and its rising threat (as deduced by the
US decision makers from aggressive and expansionist Soviet behavior). The
combined effect of Soviet power and high threat led to the ultimate adoption
of offensive realism as the grand strategy that guided the US throughout the
1950s and early 1960s.
So, they argue that the US intervention in the Korean war was realist purely from a non-ideological perspective, simply because of the perceived Soviet threat. Morgenthau, of course, argued the opposite. In fact that book even summarizes the dispute in the realist camp:
It was only later in the Cold War that these
realists, whom we call here defensive realists, began to drift away from the consensus
urging greater US intervention to limit the Soviet sphere— Lippmann
in his famous dissent from Kennan’s Mr. X article, Kennan from what he considered
the misinterpretation of his containment doctrine, and Morgenthau
even later, concerning Vietnam. Meanwhile, other realists— whom we see
as offensive realists— like Dean Acheson and Paul Nitze believed that they
were following Walter Lippmann’s realist principle of balancing goals with
the power available by expanding American and European military power to
achieve the necessary goal of preventing communist expansion into the rest of
the world. For many years, then, the realist school was divided between “hard”
(or offensive) realists, who advocated increasing Western military power to
achieve their desired goals, and “soft” or “restrained” (or defensive) realists
who advised the United States to reduce its goals to match its available power.
Also
In Kennan’s view, however, maintaining a balance of power (and thus
to safeguard diversity) required only to deny centers of industrial- military
capability from the Soviet Union, which means in practice that it was necessary
only to defend selected strong points. In contrast, NSC 68 called for the
expansion of interests, while taking into account also considerations of prestige
and credibility [...]
Changes in the balance of power could occur not only as a result of military
or economic actions, but from intimidation, humiliation, or even loss
of credibility. [...]
The threat defines the interests: Expansion of interests according to the
Soviet threat. US interests couldn’t be defined apart from the Soviet threat
to them; “frustrating the Soviet design” became an end in itself, not a
means to a larger end.
Basically, showing that the Communist camp couldn't achieve a trifling victory in their near abroad of Korea, fit in that vision. (Later repeated in Afghanistan '79, by the way, albeit by different means.)
As discussed elsewhere in that book, it's also worth noting that Kennan opposed the establishment of NATO, which he saw as "enhancing the security dilemma by encircling the Soviet Union with military alliances", so his softer approach to the Communist camp was broader than just Korea.
Finally, realists squabble over what strategy is to be called what, e.g.
Although Mearsheimer is
considered the leading offensive realist, in fact his theory with regard to US
intervention in the Cold War is not different from defensive realism because
it conceives of US behavior as balancing and not defeating the Soviets.
This is somewhat aside, but since someone [not the OP] in comments to the other answer appears interested in prospect theory in political decision making... There's is one paper by Jeffrey W. Taliaferro that combines that with defensive realism to produce what they call balance-of-risk theory. Ultimately it posits that:
Officials initiate risky diplomatic and/or military intervention strategies to avoid perceived losses.
Leaders then persevere and even escalate failing
peripheral interventions to recoup their past losses. [...] These tendencies produce policies that are driven by
concerns about power and security but are at odds with many variants of political
realism.
They illustrate that with the USSR in Afghanistan, US (and France) in Vietnam as prime examples, but don't really say anything definitive about Korea, other than that back the US considered itself in a "much stronger position vis-à-vis the Soviet Union in 1954 than it had been in 1950", which is kinda left hanging: no conclusion is drawn about anything else relating to the Korean war.
But interestingly enough such a paper does even talk about prestige being involved in the decisions to fight in the periphery:
The definition of risk offered here focuses on the potential for loss or gain.
Depending on the situation, losses and gains generally entail objective measures
of a state’s capabilities, such as military forces and equipment, territory, economic
resources, and ability to absorb military and civilian casualties. They can also involve subjective items of value that play a role in leaders’ calculations, such as
a great power’s reputation for resolve, the credibility of commitments, and prestige. [...]
Senior officials are acutely sensitive to the relative distribution of power and
prestige among the great powers. All else being equal, the greater a state’s aggregate
power—population, industrial resources, territory, military capabilities, and
technological resources—the greater a potential threat it can pose to others. A
closely related factor is prestige, a state’s reputation for having material capabilities
or status and using those commodities to achieve its desired aims. The ultimate determinant of prestige is victory in a major (or
hegemonic) war. The actual task of assessing relative power and prestige,
however, is complicated. The various measurements upon which leaders rely are
often imperfect.
It's basically implied but not said explicitly that victory in a minor, peripheric war counts for less than victory in a major war, in terms of prestige. Meh, rather obvious.
I see that the author of that paper even wrote an entire book on the topic, and in the table of contents of the latter they do have a full chapter about the Korean war, well, at least until 1951. In [not so short] summary, the author says:
I argue that loss aversion caused the Truman administration to reverse its long-established policy and intervene in the Korean War in June 1950. Officials' perceptions of relative power trends influenced the selection
of an expectation level, which in this case was the preservation of
the territorial status quo. In 1949-50, a series of adverse developments the
Communist victory in the Chinese civil war, the Sino-Soviet alliance,
and the Soviet atomic bomb-produced a profound sense of vulnerability
among decision makers. Failure to check the projected growth of the
Soviet bloc's power would result in the steady of erosion of American
power and influence by the mid-1950s. However, if the administration
took immediate steps to reverse this trend-mainly through increased
defense spending and stronger military ties to Western Europe and
Japan-the United States would remain preponderant. In the meantime,
however, Truman and his advisors concluded that major war during the
American window of strategic vulnerability (1950-53) would be disastrous. Consequently, they sought to avoid any action that might precipitate
a direct superpower confrontation, while reaffirming the priority of
European defense and the defensive perimeter in the Pacific consisting
of Japan, the Ryukus, and the Philippines.
The North Korean invasion represented a dramatic challenge to the
status quo. As balance-of-risk theory would expect, Truman and his advisors
adopted the risky strategy of committing troops to defend South
Korea, a country that officials deemed "strategically insignificant"
weeks earlier. Intervention was riskier than other options, given the
strength of the U.S. armed forces in June 1950 and the possibly that the
invasion was a diversion. Once American troops crossed the Thirty-eighth Parallel in early October, Truman and his advisors sought to recover
the sunk costs of their previous policies. They were insensitive to
the marginal costs associated with MacArthur's offensive-namely the
increasing likelihood that China would enter the war. After the Chinese
counteroffensive sent American and allied forces reeling in November
and December 1950, the administration opted to wage a limited war, despite
widespread calls at home for a unilateral withdrawal and calls
from the allies for an immediate negotiated settlement.
Offensive realism suggests that increased relative power and international
opportunity drove the 1950-51 Korean War decisions. The theory
does explain the escalation of American war aims from containment to
rollback in August-September 1950. The retreat of the North Korean
army, the diminished likelihood of Soviet intervention, and China's perceived
military weakness, gave the administration a window to reunify
the Korea at a low cost. Offensive realism, however, does not explain the
officials' intervention decision in June and their subsequent refusal to
halt the Yalu offensive despite the increasing likelihood of a Chinese
counteroffensive.
[...] Truman announced the end of the American nuclear monopoly
on 23 September [1949]. [...]
The administration faced additional setbacks, including the flight of
Chiang and the KMT army to Taiwan, Mao's proclamation of the People's
Republic of China (PRC) on 1 October 1949, and the conclusion of
the Sino-Soviet alliance treaty on 14 February 1950.
The CIA warned the "West now lagged behind the USSR in terms of total
gain of political, economic and military strength."
[...] as balance-of-risk theory would expect, NSC-68 reaffirmed the
necessity of maintaining the territorial status quo during the window of
vulnerability. After the proposed military buildup, the United States
would have the capabilities to "induce a contraction of the Kremlin's
power and influence." In the short-term, however, NSC-68 and related
documents reaffirmed the defensive perimeter strategy in the Pacific. [...]
The setbacks of the previous months made the Truman administration
sensitive to any further deterioration in relative power and credibility. The North Korean invasion on 25 June 1950 came as a complete shock [...]
officials simply assumed that the North Korean invasion
was part of a coordinated campaign of Soviet-backed aggression or
subversion. Stalin had likely intended the invasion as a diversion for a
Soviet move elsewhere or a probe of American resolve. [...]
On 25 June, Truman
told his aide George Elsey that "Korea is the Greece of the Far East.
If we are tough enough now, if we stand up to them [that is, the Soviets]
like we did in Greece three years ago, they won't take any steps."
And yeah a version of domino theory was posited even back then:
On 27 June, the president met with the congressional leadership at the
White House. Truman said that he and advisors unquestionably believed
that "if we let Korea down, the Soviets will keep right on going
and swallow up one piece of Asia after another .... If we were to let Asia
go, the Near East would collapse and no telling what would happen in
Europe."
At the 28 June NSC meeting, Acheson stated that the deployment of
ground and naval forces did not necessarily constitute "a decision to engage
in a major war with the Soviet Union if Soviet forces intervene in
Korea." However, he observed: "The decision regarding Korea ... was
undertaken in the full realization of a risk of war with the Soviet
Union."
[...] The 25-30 June intervention decisions support balance-of-risk theory.
Truman and other officials considered four options: (1) the continuation
of existing policies, (2) the use of airpower to provide cover for retreating
South Korean troops and the deployment of the Seventh Fleet to the Taiwan
Straits, (3) the use of airpower above the Thirty-eighth Parallel to
disrupt North Korean supply lines, and (4) full-scale intervention by
ground, naval, and air forces to reverse the North Korean invasion. The
administration quickly abandoned the first option and then pursued the
remaining three in succession. No option was completely free of risk and
each entailed difficult trade-offs. However, given the administration's
oft-stated desire to avoid an entrapment in an East Asian ground war or
a confrontation with the Soviets in the near term, the two latter options
entailed high risks. As the theory expects, officials pursued risk-acceptant
intervention options in the periphery as a means to avoid perceived
losses to reputation for resolve and relative power.
So yeah, although this was written some 15 years before Miller's book, and the latter doesn't cite it much, it kinda draws the same conclusion that it was a two-phase thing: defensive realism (albeit +loss aversion) that led to the later offensive realism phase, past the 38th parallel.
I'm not gonna paste much of the rest of the analysis here (you're only formally asking about the initial decision anyway), but they do say that the apparently weak Soviet response (elsewhere) and the perception that China wasn't even remotely ready to intervene with troops (CIA assements) led to the transition to the offensive [realism] phase, which is classically explained by a perception of weakness in the enemy camp.
So, yeah, this is also perhaps a good case study in the relative strengths and failings of various realist theories in explaining a sequence of events in the same theatre. OTOH, the author claims that after signs of the Chinese intervention appeared, loss aversion kicked in again [this time relative to having "acquired" in their minds the whole of Korea already], distorting US decision makers thinking back into a situation best explained by balance-of-risk theory (i.e. more like a defensive realism again).