When is the best time to take a research year?

I'm a current M1 interested in derm. I'm at an allopathic US medical school that unfortunately does not have a home dermatology program so I've been struggling to find research opportunities. I definitely want to take a research year but I don't know when is the best time to take it— after M2 or M3? I've heard from some fellow students that students who are interested in competitive specialties like derm and ortho usually take it after their 2nd year, why is that? I don't really know the downfalls/benefits of doing it after 2nd vs 3rd year. When do you think would be the best time to do it?