This post contains affiliate links. As a partner with Amazon and various brands, I am compensated when qualifying purchases are made through my referral links.
A table of contents improves the user experience. I test and measure my content with heatmaps (I use Mouseflow) and my table of contents gets a high percentage of clicks. Here is how to create a table of contents in WordPress.
If you are using Yoast Premium (compare the free and paid version of Yoast here), you can simply drop in the Yoast Table of Contents Gutenberg Block.
You can also install a free WordPress Table of Contents Plugin.