Preheat the oven to 350°F (175°C). Grease a 9x13-inch baking dish with cooking spray or butter.
In a large bowl, combine the shredded Monterey Jack cheese, shredded cheddar cheese, diced green chilies, black beans, and corn. Mix well and spread evenly in the prepared baking dish.
In another bowl, whisk together the eggs, milk, ground cumin, garlic powder, onion powder, salt, black pepper, and cayenne pepper (if using). Pour the egg mixture over the cheese and vegetable mixture in the baking dish.
Use a fork to gently stir the mixture to ensure the egg is evenly distributed.
Bake in the preheated oven for 35-40 minutes, or until the casserole is set and lightly golden on top.
Remove from the oven and let it cool for about 10 minutes before slicing. Garnish with chopped cilantro and serve with sour cream if desired.