"A prison, like a jail, is a necessary government function, and it must be located somewhere," a state circuit judge ruled.