Based on my distant recollections, I believe the line actually closed in the mid 1960's and only reopened again by default as a consequence of long distance trains from the south to Stranraer via Ayr being routed this way, via Kilmarnock and Barrassie, instead of the previous routing where trains left the main line at Mauchline and reached Ayr via Annbank. Most of this route has long since closed
Prior to closure in the 1960's, the Ayr to Kilmarnock service ran using a single coach railbus between the two towns. When the line reopened (can't remember exactly when that was), it did not do so specifically as an Ayr to Kilmarnock service but rather as a mix of longer distance services - e.g daytime and overnight services between London Euston to Stranraer Hbr, with these trains calling Dumfries, Kilmarnock, Troon, Ayr and the rest. I think there were also some Newcastle to Stranraer trains as well, which still run today.
Because of this, the service was sparse and infrequent, being only single figure services per day each way for a number of years and long gaps between services. Some of the timings also detracted from the usefulness as a local service, with the overnight train ex Euston calling at Kilmarnock at around 0330hrs and a southbound Euston leaving Ayr at around 2300 or later. However, the service frequency increased substantially when Glasgow to Girvan and some Glasgow to Stranraer trains were also re-routed this way from the more direct route via the Ayrshire coast, giving a much more even spread of services over the day. Again, can't remember when that was.
Other readers are correct in citing lack of demand being insufficient to sustain a service based purely on point to point flows between the two towns. The main pull for both towns for commuting and high end shopping is towards Glasgow rather than between each other. However, because the trains that do run cater for a mix of long and short distance flows other than specifically Ayr-Kilmarnock, there is a much more frequent service between the two than would otherwise be the case. Overall, the service is much better now than what it used to be when the route was initially reinstated, and it is certainly a lot better than having no service as at all, as was the case from mid 1960's onwards.
Other readers may well be able to elaborate further on this.