We study the magnetic, structural, and electronic properties of the recently discovered ironbased superconductor BaFe2S3 based on density functional theory with the generalized gradient approximation. The calculations show that the magnetic alignment in which the spins are coupled ferromagnetically along the rung and antiferromagnetically along the leg is the most stable in the possible magnetic structure within an Fe-ladder and is further stabilized with the periodicity characterized by the wave vector Q=(π,π,0), leading to the experimentally observed magnetic ground state. The magnetic exchange interaction between the Fe-ladders creates a tiny energy gap, whose size is in excellent agreement with the experiments. Applied pressure suppresses the energy gap and leads to an insulator-metal transition. Finally, we also discuss what type of orbitals can play crucial roles on the magnetic and insulator-metal transition.