Hi and welcome to Healthcare Magic.
The black pigmentation on your thigh is known as Post Inflammatory Hyperpigmentation/ Post Inflammatory Hypermelanosis
(PIH). It is a condition of the skin arising from trauma ( of any nature) to the skin resulting healing with pigmentation.
Now to explain in your situation, you might have had a rash
arising from either insect bite or due purpura
(extravasation of blood in skin due to many a causes) or due to so many reasons. It is a superficial skin change in first instance. But then as you scratched, it caused deeper injury
to the skin. Due to this deeper injury it stimulated the melanocytes (the color producing cells of the skin) which turned the rash into black pigmentation. This is totally a normal process which is a part of healing phenomenon in any injury to skin. So if the injury is superficial it does not generally leave a mark but if the injury is deep it will leave blackish brown mark. PIH is an asymptomatic (without any symtom of pain or itching) condition.
Now you should also understand that our skin is daily renewing itself so the pigmentation which is deeper it gets lighter as the skin is renewed. After few years of period it will be faintly visible or not visible at all !!
I hope you got your answer and next time you will ask the person in circle that not to scratch or rub any injury/ Rash.
With best health wishes
Dr Sanjay K Kanodia