In Texas the state takes all fines over a certain amount or percentage of violations. So, the localities do everything in their power to jack up court fees and pretty much push you into a diversion program...which costs as much or more than the ticket but does not go on your record.
It is almost exclusively about revenue.
Yeah, usually defensive driving will cost the same as paying the ticket, you just have to pay for the class also.
I got a ticket in Pasadena, TX once. The cop on scene pretty much told me to ask for deferred adjutication if I had a clean record. I showed up in court and asked for that. It cost the same, but the ticket went away after 3 months with no further tickets. I don't think they really cared. When I got the ticket, one cop was waving everyone over who was going more than 10 MPH over the limit. The other cop was writing all the tickets for 10 MPH over. They did that in that location quite often. It was right before a speed limit change and everyone tended to speed up early.