Preheat your oven to 375°F (190°C) and bring a large pot of salted water to a boil. This temperature will ensure the shells bake evenly without burning the cheese.
Cook pasta shells according to package directions, minus 2 minutes to keep them slightly firmer than al dente. They'll continue cooking in the oven, so undercooking prevents them from becoming mushy.
Drain shells carefully and lay them out on a baking sheet to prevent sticking. A light coating of olive oil can help prevent them from sticking together while you prepare the filling.
Brown the ground beef in a large skillet over medium heat until no longer pink, about 5-7 minutes. Break it into small, even crumbles as it cooks for the best texture.
Add onions and garlic to the beef and cook until onions are translucent, about 3-4 minutes. The aromatics will infuse the meat with flavor.
If using fresh spinach, add it to the skillet and cook until wilted, about 2 minutes. If using frozen spinach, make sure it's thoroughly drained and add it now, stirring to combine with the beef mixture.
Remove the skillet from heat and let cool slightly, about 5 minutes. This prevents the egg from cooking when added to the mixture.
In a large mixing bowl, combine ricotta, 1 cup mozzarella, Parmesan, egg, Italian seasoning, salt, and pepper. Mix until well incorporated.
Fold in the cooled beef and spinach mixture until evenly distributed throughout the cheese mixture.
Spread 1 cup of marinara sauce in the bottom of a 9x13 inch baking dish, creating an even layer to prevent the shells from sticking.
Fill each pasta shell with a generous spoonful of the beef and cheese mixture and arrange them in the baking dish, open side up.
Pour the remaining marinara sauce over the stuffed shells and sprinkle with the reserved ½ cup of mozzarella cheese.
Cover with aluminum foil and bake for 25 minutes, then remove foil and bake for an additional 5-10 minutes until cheese is bubbly and slightly golden.
Let stand for 5 minutes before serving to allow the filling to set. Garnish with fresh basil just before serving.