Bring a large pot of salted water to a boil. Add the spaghetti and cook according to the package instructions until al dente. Reserve about ½ cup of pasta water, then drain the spaghetti and set aside.
Heat the olive oil in a large skillet over medium heat. Add the chopped onion and cook until soft and translucent, about 5 minutes. Stir in the minced garlic and cook for another minute until fragrant.
Add the ground beef to the skillet with the onion and garlic. Use a wooden spoon to break the meat apart. Cook until browned and cooked through, about 7-8 minutes. Season with salt, pepper, and Italian seasoning.
Pour in the marinara sauce and stir to combine. Let the sauce simmer for 10 minutes, allowing the flavors to meld. If the sauce is too thick, add a little reserved pasta water to loosen it.
Reduce heat to low. Stir in the ricotta cheese until creamy and evenly mixed. Then add half the mozzarella and Parmesan, stirring gently until the cheeses start to melt into the sauce.
Add the cooked spaghetti directly into the skillet with the sauce and cheese mixture. Toss everything together carefully, ensuring each strand is coated. If needed, add a splash of pasta water to achieve your desired consistency.
Sprinkle the remaining mozzarella and Parmesan cheese over the top. Cover the skillet briefly to let the cheese melt, about 2-3 minutes. Garnish with fresh basil leaves before serving.