The quantum entanglement between two excitons in two-dimensional materials, embedded in an optical microcavity, was investigated. The energy eigenstates of a Jaynes-Cummings like Hamiltonian for two qubits coupled to a single cavity mode have been calculated. The quantum entanglement between such states was estimated by calculating the concurrence between two qubits in each of these eigenstates. According to the results of our calculations, if the system is allowed to decay only through the emission of cavity photons at low temperatures, there is a maximally entangled eigenstate, protected from decay. We demonstrated that the existence of such a state results in the counter-intuitive conclusion that, for some initial states of the system, the fact that the cavity is leaky can actually lead to an increase in the average concurrence on the timescales of the average photonic lifetime. In addition, we calculated the time evolution of the concurrence between a pair of excitons in a strained graphene monolayer.