In recent years, animal cleanliness during production has gradually attracted increasing attention. Although pigs by nature tend to excrete in dark and humid corners, in the prevalent highly intensive pig production, excessive stocking density often restricts the ability of pigs to excrete at designated points, thereby leading to pollution of the pens. To study the effect of stocking density on pen cleanliness and the relevant pig behavior, a total of 216 Landrace × Yorkshire × Duroc hybrid pigs were randomly grouped at 0.5, 0.7, or 0.9 m2 per pig at 59 ± 3 days of age. The temporal and spatial distributions of lying and excreting behavior of pigs were monitored on days 1, 7, and 35 after transfer, and the cleanliness of pig pens under three stocking densities was scored. The results showed that there were no significant differences in excreting or lying time rhythms among the three treatments. In the initial and stable periods of group transfer, the excretion rate of pigs on slatted floors was significantly higher than that on solid floors at 0.9 m2/pig (p < 0.01). During the group stabilization stage and at the end of the experiment, the lying rate of pigs on solid floors under 0.9 m2/pig was 10.81%, that is, 7.43% higher than that of 0.7 m2/pig, and the differences were significant. Judging from the pollution score of the solid floors, the three stocking densities all showed more serious pollution at the corners, and the pollution score of the pens with a density of 0.9 m2/pig was lower than that of the pens with a density of 0.5 and 0.7 m2/pig. The analysis of whether pigs had corresponding behaviors in specific functional areas showed that pigs at a density of 0.9 m2/pig had a 10.14% lower lying rate on slatted floors (the expected excretion area) than on solid floors, whereas the densities of 0.5 and 0.7 m2/pig showed the opposite pattern. Pigs at a density of 0.9 m2/pig had lower excretion rates in both corners of the solid floors (the desired lying area) than that of the 0.5 m2/pig group (p < 0.05) and 0.7 m2/pig group (p > 0.05). These results indicate that when the effective occupied space of pigs was larger, specific behaviors were more likely to occur in the set functional areas, and the cleanliness of the pen was higher. Under the conditions of this experiment, the recommended stocking density for growing pigs was 0.9 m2/pig. Of course, a larger space may be more beneficial to animal health and welfare, but the economic costs must also be considered.