If you've had the microwave for a few years, it's likely that the magnetron tube is wearing out, and it needs to be replaced. I suggest that you have a professional service person diagnose the power circuit to make sure of this. It's not really a DIY job, because there's 4,000 volts produced in the circuit, and it requires special testers to analyze the problem. The magnetron costs between $125 and $150.
If my answer helps you, please click on the 'accept' button. That's how we experts are paid for our efforts.