Minecraft wiki entry for Improving_frame_rate, associated text: Close any programs in the background, including any internet browsers like Chrome, Opera, and Firefox, or at the very least minimize them.
On Windows, open Task Manager and go to the details section, find javaw.exe (the one the game uses), right click it and set its priority to "High" (not "Realtime", as realtime will try to allocate all of the PC's resources (RAM/CPU/GPU) to the game, not leaving enough for Windows to function, causing it to freeze or even blue-screen).
Make sure you have enough RAM available (in a program such as a task manager), else your computer may swap to disk, which could cause the game to stutter intermittently.
On laptops and most pre-built desktops, uninstall bloatware.
Do frequent malware scans with an antivirus program, to ensure no malicious programs are consuming computer resources.
Do not run other CPU- or GPU-intensive programs while the game is open.
On Windows Vista through Windows 7, disable graphical effects such as Windows Aero and taskbar transparency.
Disable compositing (sometimes called "desktop effects") on GNU/Linux. When compositing is disabled, all window managers tend to give similar performance, so there is no need to use a "lightweight" one.
Update your graphics card drivers. You can find these on your GPU manufacturer's website.
Disable anti-aliasing and anisotropic filtering in your GPU driver settings.
Ensure the computer is running at a cool enough temperature so as to not cause thermal throttling. This is especially effective for laptops and older desktops. If the computer is too hot, look into cleaning out dust.
Reduce the display resolution. Play Minecraft in windowed mode and make it about half the size of your screen.
You may be able to switch your operating system to a Linux distribution, depending on what you use your computer for. Linux distributions are generally easier on the computer's resources compared to Windows. However, it is important to research hardware/software compatibility (for example, Nvidia graphics cards) before switching operating systems. This makes the most effect on AMD graphics cards, which can see a 2x performance improvement from Linux drivers on OpenGL games such as Minecraft!
If you are playing on a desktop computer, look into upgrading your graphics card, which can help the game render objects faster.
For Windows users: Try using Minecraft for Windows instead of Minecraft Java Edition if you are not using a Java-exclusive feature (such as mods). Minecraft Bedrock generally has smoother performance than Java.