The requirement that the tefillin be square is among the classic laws that are listed as halachah leMoshe miSinai (lit., "the law of Moses from Sinai"), halachic traditions that are not stated—directly or indirectly—in a verse, but rather were transmitted orally by G‑d to Moses and were passed down through the generations.1
The Talmud gives no actual reason for the squareness of the tefillin. In fact, this is sometimes given as an example of a law whose details cannot be understood, even if the general reason for the mitzvah is revealed to us. In this case, we understand that the tefillin are to function as “a sign upon your hand, etc.,”2 but we do not know why the sign must take this particular shape. This tells us that even that which we do understand is only part of the reason for the mitzvah, which is beyond the grasp of our limited, mortal minds.3
We are nevertheless instructed to seek as much explanation as possible.4 Here are some of the classic reasons for tefillin’s squareness.
A Dwelling for G‑d
The Zohar states that the secret reason for the mitzvah of tefillin can be found within the verse, “And they shall make Me a sanctuary and I will dwell among them,”5 which refers to the Tabernacle.6
The Kabbalists explain that the term “among them,” בְּתוֹכָֽם, can be read as בְּתוֹכָֽ-ם “within the [closed] mem,” which is square shaped. Thus, the closed square mem represents the four “sides” (directions) of the world and the square shape of the Holy Temple.7
The Midrash8 famously points out that the verse should have stated, “And they shall make Me a sanctuary and I will dwell in it.” Instead it states, “I will dwell among them,” referring to G‑d’s dwelling within the people themselves. How do we fulfill this mitzvah today, without an actual Temple? By putting on tefillin, we elevate ourselves and make our own bodies into a dwelling for the Divine (see here for why this does not apply to women). In light of this, we are told to make the tefillin square-shaped, similar to the shape of the Holy Temple and the letter mem.9
Round Creations
Another reason given is based on the statement of the Jerusalem Talmud that nothing square was created during the Six Days of Creation.10 Thus, the square represents that which man refines or processes. Square tefillin, therefore, symbolize our mission to uplift the material and mundane world and infuse it with holiness, and ultimately make it into a dwelling place for the Divine,11 which will be fully realized with the coming of the Messianic era. May it be speedily in our days!

Re: “ the statement of the Jerusalem Talmud that nothing square was created during the Six Days of Creation” — but there are definitely square things in nature! All mint plants, for instance, have a stem that is square in cross-section — and every grain of salt is a cube: with six square sides.
I think when the Sages said “square” it really meant what we call a perfect cube, i.e. a three dimensional square. Please bear in mind that back then it’s possible that certain Hebrew words for geometric shapes weren’t yet fully developed.
This makes sense because the religious article referred to, Tefillin, is a perfect cube, meaning a three dimensional square. I am not presently aware that such a structure occurring in nature.
Grains of salt are perfect cubes. Look add them under a magnifying glass or microscope.. other perfect cubes in nature include the crystal formations of a mineral called “pyrite. “ To see these and more, search Google for “perfect cubes in nature. “