If it's not cleaning well, there's a good chance that you haven't kept up with regular maintenance. To avoid the cost of replacing it with a new dishwasher, you need to make sure that you keep on top of cleaning it out (including the filter) and using the cleaning rinse cycle.
When you put in the work to keep your dishwasher clean, you will see the results in the cleanest dishes your machine is capable of. Always remember that you can experiment with different cleaning solutions, liquids, and tablets to see which will work best with your machine. But, for the most part, sticking to a cleaning schedule for the device itself will bring the best results out of every cycle.