Because past participles that take 'avoir' as an auxiliary only agree with a direct object which is placed before the auxiliary. In this example 'lettre' is the direct object of 'écrit', and comes after the 'a', so no gender agreement. Consider this construction: 'La lettre qu'il lui a écrite' - before the 'avais' auxiliary, so 'écrite' agrees with it by gender and quantity. HTH
This sentence can't be "Il m'a écrite une lettre" even if "me" refers to a female since participles don't agree with indirect objects. Am I right?
Yes, they don't agree with indirect objects, but it also doesn't agree with its direct object here, 'lettre', because it comes after the auxiliary 'avoir'. Alternatively the sentence could have been rendered 'La lettre qu'il lui a écrite', in which case we see the gender agreement by the participle. HTH
in a choice of six options the given answer did not feature, meaning that it was impossble to give a correct response