Preheat oven to 375°F. Boil sweet potato cubes in salted water for 15-20 minutes until very tender. Drain and mash with butter and milk until smooth. Season with salt and pepper and set aside.
Heat olive oil in a large skillet over medium heat. Sauté onion and bell pepper until softened, about 6 minutes. Add garlic and cook for 1 minute more.
Add black beans, corn, diced tomatoes, chili powder, cumin, smoked paprika, and cayenne if using. Stir well and cook for 5 minutes until heated through. Season with salt and pepper.
Stir half of the shredded cheese into the bean mixture. Transfer to a 9x13 inch baking dish and spread evenly.
Spread the mashed sweet potatoes over the top of the filling, using a spatula or fork to create peaks. Sprinkle remaining cheese on top.
Bake for 25-30 minutes until heated through. Turn on the broiler for the last 2-3 minutes to lightly brown the peaks of the sweet potato topping. Let cool for 5 minutes before serving.