In written German
First off, note that in written German "warum" easily surpasses all of its alternatives, as Google Ngram (see other answer) and DWDS corpus search show.
And because all of "warum", "wieso", "weshalb" and "weswegen" are widely regarded as synonyms writers will exchange those words for each other just for more variety.
To compare the words' frequencies in written German, it is important to know that "weshalb" and "weswegen" can also be used to mean "deshalb", "deswegen" ("because of this"). A big part of the matches in the DWDS corpus search use the words in this sense, e.g.
Seine Haut ist mit Knorpelkörnern durchsetzt und kohlenschwarz, weswegen man ihn auch den Schwarzen Wal nennt.
So "weshalb" and "weswegen" are actually even more rarely used than Ngram suggests.
In spoken German
Cooperative or not?
The important distinction would thus be between "warum" and "wieso".
The difference in spoken German has recently studied by Egbert and Vöge (2008)(restricted access) and by Volodina (2021)(free, German). They found out that "warum" and "wieso" have fixed roles in conversation. They argue the following:
"Wieso" is an information request. Basically: Tell me more about it.
Inge: ich wollte ihm die uhr dranmachn aber das ging nich
Anna: wieso nich?
Inge: die is- die is das ding hier abgebrochn
(The above is written as spoken, so not confirming the spelling rules.)
Inge was expecting the question and continues explaining.
"Warum" is used for "challenging". Basically: "Something does not make sense for me, please explain" or even "I disagree. Please explain."
Their examples are a bit too long. Something similar I made up:
Vater: Rennt nicht so. Vergesst nicht, dass wir auch wieder runtermüssen.
Kind: Warum? Berg runter ist doch nicht anstrengend.
They found that a warum question was often followed by an unnaturally long gap and often a third party intervening. (what makes their examples long)
They also found out that while in the everyday conversation corpus, "wieso" dominated "warum"(40:30), in a corpus of business meetings, there was almost no "wieso" and all "warum"s were uttered against someone lower in hierarchy. Data from school lessons (Volodina) also showed that in a hierarchical setting, almost no "wieso" occurs. But the few occurrences of "wieso" were mostly from pupil to teacher, although most of the speech was from teacher to pupil.
As a learner, I would not care about the difference, as most Germans also don't. Intonation is much more important in determining if something is a challenge or genuine question. Replacing all "wieso" with "warum" would probably not make anything sound strange at all.
While not explicitly mentioned, I think that "weshalb" and "weswegen" are a bit more formal and do not occur in spoken German that often.