The correct option is
B write
In order to fill in the blank with the most suitable form of the infinitive, we need to understand the meaning and usage of 'would rather'. 'Would rather' means preferring something or someone over the other. If 'would rather' is used in a passive (voice) sentence, we use the word 'to' along with the verb. In an active sentence, we do not use 'to' with the verb. The verbs without the marker 'to', are called bare infinitives.As the given sentence is in the active voice, we will use the bare infinitive here.
Option A - 'Writing' is the participle form of the verb 'write'. As we need a bare infinitive (without the marker 'to'), we can't use 'writing' here. Hence, option A is incorrect.
Option B - 'Wrote' is the past form of the verb 'write'. As we need the verb in its original form, we can't use 'wrote'. Hence, option B is incorrect.
Option C - 'To write' can't be used here as the verb in its original form with the marker 'to'. As the sentence is in the active voice, we can't use the infinitive with 'to' here. Hence, option C is incorrect.
Option D - 'Write' is a verb in its original form, and is a bare infinitive. Hence, option D is the correct answer.
'In order to pass the test, I would rather write than read.'