A first-principles study intense on the density functional theory (DFT) is used to assess the structural, optical, mechanical and electrical properties of RGaO3 (R = Ca, Mg) perovskites. The influence of calcium gallate (CaGaO3) and magnesium gallate (MgGaO3) are explored on structural, optical, electrical and mechanical properties. The structural properties of such compounds are computed employing Perdew–Burke–Ernzerhof and generalized gradient approximation (PBE + GGA). The generalized gradient approximation proposed by Perdew, Burke and Ernzerhof approximation is used to compute the electronic bandgap, total and partial density of states (TDOS and PDOS). The indirect band gaps of CaGaO3 and MgGaO3 were intended to be 3.28 eV and 1.84 eV, correspondingly, showing that the both materials are semiconductors. The valence band is constituted by 4s-states of calcium atoms, 3s-states of magnesium atoms and 2p-states of oxygen atoms, as per the PDOS of the examined materials. The mechanical properties of perovskites such as: ductility, elastic moduli, and elastic anisotropy, were evaluated and conferred. According to the results of these calculations, the elastic moduli of CaGaO3 has been increased. The estimated Pugh's and Poisson's ratios of CaGaO3 are 3.3472 and 0.3641. Additionally, the optical characteristics of the title compounds are estimated using the Kramer–Kroning relations. The materials' dielectric functions, optical conductivity, refractive index, absorption coefficient, extinction coefficient, reflectivity and energy loss function, are all computed as well. These findings demonstrate that CaGaO3 has better characteristics for usage in optoelectronic applications than MgGaO3.