*Noli Me Tangere* was written in Spanish because it was the official language of the Philippines during Spanish colonization. Rizal chose Spanish to reach a wider audience, including Spanish officials and the educated elite of the Philippines.
He believed that by writing in the language of the colonizers, he could effectively criticize the abuses of Spanish rule and inspire Filipinos to fight for their freedom.