The observation of ferromagnetic order in a monolayer of CrI$_3$ has been recently reported, with a Curie temperature of 45 Kelvin and off-plane easy axis. Here we study the origin of magnetic anisotropy, a necessary ingredient to have magnetic order in two dimensions, combining two levels of modeling, density functional calculations and spin model Hamiltonians. We find two different contributions to the magnetic anisotropy of the material, both favoring off-plane magnetization and contributing to open a gap in the spin wave spectrum. First, ferromagnetic super-exchange across the $\simeq $ 90 degree Cr-I-Cr bonds, are anisotropic, due to the spin orbit interaction of the ligand I atoms. Second, a much smaller contribution that comes from the single ion anisotropy of the $S=3/2$ Cr atom. Our results permit to establish the XXZ Hamiltonian, with a very small single ion anisotropy, as the adequate spin model for this system. Using spin wave theory we estimate the Curie temperature and we highlight the essential role played by the gap that magnetic anisotropy induces on the magnon spectrum.