In this study, the structural phase transition and optoelectronic properties of perovskite-hydride MgFeH3 under high pressure have been performed by ab initio calculations based on GGA-PBE functional. The phase transitions were observed from the cubic structure (Pm (3) over barm) to the orthorhombic (Pmn2(1)) and (Pmmn) structure. During the phase transition, the R (3) over barm,P1, Pm and P2121(2) intermediate phases were predicted. The energy-volume (E-V) relationships show that the most stable phase is Pm (3) over barm. The lattice parameters and volume increased as based on the phase transforms. From the electronic band analysis, the MgFeH3 shows a metallic character from the cubic to orthorhombic structure. The MgFeH3 indicates the peaks at 2.67 eV (464 nm) for Pm (3) over barm phase, 5.21 eV (238 nm) for Pmn2(1) phase and 2.63 eV (471 nm) for Pmmn phase. Pm (3) over barm and Pmmn phases correspond to the visible region. The absorption peaks are getting wider and have higher magnitude from Pm (3) over barm to Pmmn phase. The optical conductivity for the cubic structure with Pm (3) over barm phase was found to be higher than orthorhombic structures with Pmn2(1), and Pmmn phases. The reflectivity maxima decrease from Pm (3) over barm to Pmn2(1).