We explore the possibility of the production of Si polytypes via the total energies and free energies obtained in the density-functional theory and the density-functional perturbation theory. We first calculate the total energies of three polytypes of the tetrahedrally coordinated $s{p}^{3}$ Si atoms having the two-layer, three-layer, and four-layer stacking periods in the hexagonal unit cell (``$2H$'', ``$3H$'', and ``$4H$'') as a function of the in-plane lattice constant $a$ using the local-density approximation (LDA) and generalized gradient approximation (GGA) comparatively. In the LDA calculation, the $4H$ phase is energetically the most favorable among three phases in the range of 3.55 \AA{} $\ensuremath{\le}$ $a$ $\ensuremath{\le}$ 3.73 \AA{}. While the $4H$ phase is found to be more stable than the $2H$ phase at a relatively wide range of the $a$ value we studied, the $2H$ phase is found to be more stable than the $3H$ ($3C$) phase in the range of 3.57 \AA{} $\ensuremath{\le}a\ensuremath{\le}$ 3.61 \AA{}. In the GGA calculation, on the other hand, the $4H$ phase becomes the most favorable phase for almost the same range as the LDA case, 3.57 \AA{} $\ensuremath{\le}a\ensuremath{\le}$ 3.73 \AA{}. The $2H$ phase also becomes as stable as the $3H$ phase as in the case of the LDA around the small $a$ value of 3.62 \AA{}, although the $3H$ phase energy is always lower than that of the $2H$ phase in the GGA calculation. Considering the chemical vapor deposition (CVD) growth process, we calculate the biaxial stress values to reduce the lattice constant of the substrate Si crystal to realize the small $a$ values, which can lead to the homoepitaxial growth of the $4H$ phase. The values obtained are 4.69 GPa and 8.14 GPa for the LDA and GGA, respectively. Next, we study the thermal effect on the relative stabilities of the 3 phases. We calculate the phonon dispersion, bulk modulus and thermal expansion including the vibrational and thermal effect. From the comparison with experimental values of the $3C$ phase, it is found that the LDA results show much better agreement with experiment than the GGA, indicating that the LDA calculation is reliable to predict thermal properties of the real systems. Finally, we derive the free energy as a function of $a$ under several designated temperatures. The relative stabilities of the $2H$ and $4H$ phases with respect to the $3H$ phase are found to be enhanced. At around $a=3.65$ \AA{}, stabilities of $2H$ and $4H$ phases relative to the $3H$ phase become most prominent. Although stabilities of the $2H$ and $4H$ phases relative to the $3H$ phase are reduced with increasing temperature at around $a$ = 3.60 \AA{}, $2H$ phase is found to be as stable as $3H$ and $4H$ phases at higher temperatures, indicating the possibility of the production of the $2H$ phase via high-temperature CVD process with the biaxial stress.