Legal compliance in prisons ensures that the rights of inmates are protected and that prison operations adhere to established laws and regulations. It involves balancing security needs with human rights standards to prevent abuses and promote rehabilitation.