Rinse the chicken and place it in a large pot. Add the onion, ginger, star anise, cinnamon stick, and water. Bring to a boil, then reduce heat and simmer for 60-90 minutes, or until the chicken is cooked through.
Remove the chicken from the pot and let it cool slightly. Shred the chicken meat and discard the skin and bones.
Strain the broth through a fine-mesh sieve to remove any solids. Return the broth to the pot and add the fish sauce, salt, and sugar. Bring to a boil.
Cook the rice noodles according to package directions. Drain and rinse with cold water.
Divide the noodles among bowls. Top with shredded chicken, green onions, cilantro, and bean sprouts. Pour the hot broth over the noodles and garnish with lime wedges and chili peppers (if using).