You don't state whether your on city sewer or your own septic. If you are on septic, it might need to be pumped out. A lot of people with septic don't realize that
septic tanks need to be pumped/cleaned out every 3 to 5 years, depending on usage. This could account for why sometimes the toilet is flushing fine, but not every time--because the septic is draining into the lines running out from the septic tank (like it is suppose to), but you're getting the bad flushing when the septic tank is more full. If this is your problem, soon the septic will back up into your home and be a very big mess.