so in the end all that matters is the rank?
No. The difference between each student most certainly matters. A situation where 1st, 2nd, 3rd are on say 95, 94, 93, would yield a considerably different result to say 95, 85, 84.
It is a combination of factors that affect your final assessment mark. What's important is you gain as many marks as possible in school. Remember, your marks determine your rank; your rank does not determine your mark.
Even if you have sat a difficult school assessment, the intent of moderation is to ensure all schools can be fairly compared with each other. If your assessments were objectively more difficult, but your cohort is quite capable, this will reflect in your HSC exam marks most likely being higher. This would likely result in an upwards moderation of your assessment marks.
But again, what's important is you get as many marks as possible, and be as close to first as possible. This will reduce the impact to you of a cohort that performs variably or unreliably in the HSC exam. In the end, you will receive a reasonably fair mark that reflects both your performance throughout the year, and your performance on the day. This process is well and truly tried and tested.
Also note that NESA submits your HSC marks to UAC who calculates your ATAR (in NSW).