Heat oven to 375°. Combine ricotta, spinach, and egg and season with salt and pepper; set aside.
Heat oil in medium skillet over medium heat. Add tomatoes and cook until soft and juices release. Add garlic and balsamic and cook for 30 seconds. Remove from heat, stir in quinoa, and season with salt and pepper.
Lightly grease a 2-quart gratin dish. Spread half the quinoa mixture in dish. Top with ricotta mixture and half the mozzarella. Top with remaining quinoa and mozzarella. Bake until browned and bubbling, about 45 minutes.
Let sit for 15 minutes before serving topped with basil.