It’s a World Health Organisation (WHO) requirement into/out of certain destinations and it has been a requirement going into Australia for years, so half hearted or not is something that is taken pretty seriously by the powers that be and it has to be done when regulations demand it.
It’s usually done to prevent disease (e.g. dengue fever, malaria ) carrying insects leaving an area or insects getting into a country that might cause problems for e.g, the local fruit and vegetable industry.
Not sure what the composition of the spray is, the WHO have a list of acceptable chemicals for use on passenger aircraft.
FWIW the cabin crew are usually required to hand over the empty sprays on arrival to the inbound port authority officials to show spraying has been done ....and in the case of Oz we used to have to confirm over the radio with company prior to landing that spraying had been done “in accordance with Australian requirements”, it is certainly not something done on a whim or just because the airline feels like it and there can be serious sanctions if it is found to have not done properly....