We study the magnetic proximity effect on a two-dimensional topological insulator in a CrI$_3$/SnI$_3$/CrI$_3$ trilayer structure. From first-principles calculations, the BiI$_3$-type SnI$_3$ monolayer without spin-orbit coupling has Dirac cones at the corners of the hexagonal Brillouin zone. With spin-orbit coupling turned on, it becomes a topological insulator, as revealed by a non-vanishing $Z_2$ invariant and an effective model from symmetry considerations. Without spin-orbit coupling, the Dirac points are protected if the CrI$_3$ layers are stacked ferromagnetically, and are gapped if the CrI$_3$ layers are stacked antiferromagnetically, which can be explained by the irreducible representations of the magnetic space groups $C_{3i}^1$ and $C_{3i}^1(C_3^1)$, corresponding to ferromagnetic and antiferromagnetic stacking, respectively. By analyzing the effective model including the perturbations, we find that the competition between the magnetic proximity effect and spin-orbit coupling leads to a topological phase transition between a trivial insulator and a topological insulator.