Hybrid inorganic perovskites (HIPs) have been developed in recent years as new high-efficiency semiconductors with a wide range of uses in various optoelectronic applications such as solar cells and light-emitting diodes (LEDs). In this work, we used a first-principles theoretical study to investigate the effects of phase transition on the electronic and optical properties of CsPbI3 pure inorganic perovskites. The results showed that at temperatures over 300 °C, the structure of CsPbI3 exhibits a cube phase (pm3m) with no tilt of PbI6 octahedra (distortion index = 0 and bond angle variance = 0). As the temperature decreases (approximately to room temperature), the PbI6 octahedra is tilted, and the distortion index and bond angle variance increase. Around room temperature, the CsPbI3 structure enters an orthorhombic phase with two tilts PbI6 octahedra. It was found that changing the halogens in all structures reduces the volume of PbI6 octahedra. The tilted PbI6 octahedra causes the distribution of interactions to vary drastically, which leads to a change in band gap energy. This is the main reason for the red and blue shifts in the absorption spectrum of CsPbI3. In general, it can be said that the origin of all changes in the structural, electronic, and optical properties of HIPs is the changes in the volume, orientation, and distortion index of PbI6 octahedra.