(condensed from Ein Ayah, Shabbat 1:42)
Gemara: Rabbi Chanina says: A person is required to examine his clothes [for objects he might come to carry] on Friday evening as night falls. Rav Yosef said: This is a major halacha for Shabbat.
Ein Ayah: One of the foundations of the sanctity of Shabbat is to raise "external life" to a similar level to that of "internal life" with the help of the latter. This is important because the farther the distance between these two elements of a person’s life the worse his situation is and the farther he will be from the character that Hashem, Who desires his success, set for him.
Sanctity, rest, and refinement are special positive contributing factors of a person’s internal life when one engages in them with purity in a complete manner. These elements are apt to be very far from the external lives of those who have complicated their lives with all sorts of agendas that people entertain while forgetting that Hashem created them to be straight (see Kohelet 7:29).
Shabbat comes to deal with these issues. Its sanctity returns the power of the internal life, which was weakened by the opposing external life when the latter exists in a polluted form. Shabbat also has the ability to impact external life and make it much closer to the internal one, by providing it with an infusion of tranquility, sanctity, refinement, and charm.
Therefore, one should be careful to follow Shabbat properly even in regard to external elements of its observance. For this reason, the Rabbis forbade many things because of marit ayin (the appearance of impropriety) on Shabbat. Similarly, many matters of external behavior were regulated by the decrees of the prophets. For example, Yeshaya said: "You shall show it [Shabbat] respect" (Yeshaya 58:13), which teaches us that clothes for Shabbat should be nicer than those for weekday. In these matters, external honor and sanctity is more important than the internal essence so that they can impact, by providing a spirit of sanctity and calmness, on one’s external life, which is the part that requires the most improvement.
There are practices that are not essentially spiritual desecrations of Shabbat, but when they exist on a regular basis, they dull its sanctity. Because of Shabbat’s nature, it becomes necessary to be careful about such matters. Fundamentally, if one leaves an object in his clothing, it is not a full desecration of Shabbat, as carrying it into the street is done by means of mitasek (an act done without awareness of its ramifications), as Tosafot (Shabbat 11a) says. However, regarding the external element of the action, the intention of one’s heart does not create distinctions, and if one carries even without knowing that he is carrying, the sanctity of Shabbat is still defiled.
Therefore, one is to examine his clothes right before Shabbat to make sure that even the external nature of Shabbat will not be affected. Rav Yosef adds that this is a major halacha of Shabbat because it is part of a general effort to have the sanctity of Shabbat extend, from its lofty internal level, to a person’s external element. This is something that is great both in terms of quantity [of actions] and in terms of quality, which enhances Shabbat and protects its character. It enables one to reach the goal of bringing the sanctity of the external closer to that of the internal life of spiritual intellectuality and morality that a person, as one who was created in the image of Hashem, is capable of reaching.