Dear
@Nay,
thank you for your question in the community. If you have B2/C1 German skills, then you could try already after 5 years. It doesnt effect negatively your stay if you apply before 8 years.
There is not a real ideal time, as it depends on the particular case.
If you have further questions please do not hesitate to reach to us.
Best regards,
Nilab