1. Preheat the oven to 400 degrees F and set a rack in the upper position. Set the casuelas on a baking sheet.
2. For the sauce: Heat the olive oil and onions in a medium saucepot set over medium-high heat. Season the onions with salt and pepper and cook until soft, 5 to 6 minutes. Add the garlic and crushed red pepper and stir until fragrant, about 1 minute. Add in the pepperoni and cook until the pepperoni gets slightly crispy around the edges and releases some of its oil, 2 to 3 minutes. Pour in the tomatoes, add the basil leaves and season with salt and pepper. Reduce the heat to medium-low and gently simmer until the liquids reduce and the flavors intensify, about 35 minutes.
3. Once the sauce is ready, make the polenta: In a saucepot over medium-high heat, bring the chicken broth and half-and-half to a boil. Season the liquids generously with salt, and then stream in the polenta, stirring constantly (be careful, polenta can splatter when it cooks). Continue to stir and cook the polenta until it absorbs all the liquid, 3 to 4 minutes; it will still be very loose and creamy. Add in the Parmesan, taste and season again if needed.
4. Divide the polenta among the casuelas. Use a spoon to push the polenta toward the edges of the dish, creating a well to place some sauce. Then take about 1/2 cup of tomato sauce and pour it into the center of the polenta. Again, use a spoon to make a well so you can crack an egg into the very center of the dish. Crack the eggs into the center of each dish and place into the oven to cook until the eggs just set and stop jiggling when shaken, 17 to 20 minutes.
5. When the eggs come out, garnish each dish with a generous dollop of ricotta cheese, a drizzle of olive oil and a sprinkling of salt and pepper.