Because the "court cost" doesn't just cover the rental of the court room, it covers all the expense of processing your ticket. The fine is supposed to be pure profit for the municipality.
If you are found not guilty, you usually do not have to pay costs.
Sometimes there are deals where you can avoid conviction if you pay the costs. Financially not a great thing, but it keeps your insurance company from finding out and raising your rates.