This is somewhat of a distant concept in high school, so I think you brought up a great question. First, let's look at how schools are ranked. There are two general fields for ranking: primary care, and research. Generally when we just talk about "top schools" people are discussing the latter. So why does research make a school "better" and how is it calculated? Well, it doesn't really. It's calculated based on how much NIH funding comes in, among other things, regardless of whether that money is applied to med student education or not. In ~2006 Boston University put up two major biomedical research buildings. At the time, the space was mostly empty still. Few med or grad students used the facilities at all. In fact, they had to hire in a lot of surrounding researchers just to get labs going. And despite these efforts in no way affecting the medical school curriculum or learning experience, the med school ranking shot up.
By now in your high school career, you've come across teachers who promote active learning. That's the majority of med school. In third year after you've seen a patient with some disease you don't know much about, no one will teach you. You have the choice of going home and reading about it yourself, or not. There are no professors. No lecturers. No syllabus or day planning as far as learning goes. Your supervising attending may give you a few factoids, but the depth of your knowledge on that topic is self-motivated. You can easily learn a lot or a little at any med school accordingly.
Now why is it that the "lower ranked" med schools don't "have better residency placements?" Difference of focus. The people who go to med schools who are ranked poorly in research and highly in primary care teaching, on average, have a higher likelihood of wanting to go into primary care. Whereas dermatology pretty much requires research in the field to get into a residency. Even if your school doesn't require research, you can still do it if that's the field you want. But again, people who go to the non-research driven schools are more likely to not want to do research or research-driven fields. Also, people who get into "top ranking" schools generally have better standardized test scores and grades. When they are similarly evaluated in med school with standardized tests, they have a habit of performing well, which repeats the cycle. That doesn't mean the USMLE Step 1 is somehow harder for people in primary care driven med schools. It's the same test.
Bottom line: get through high school and college. Get into the best med school that has the type of community and setup that feels right to you, then worry about residency. You may not realize it in high school, but the road is long and you won't know for sure if you like dermatology until you do it in med school.