The dedicated server files for each version (minus some very old lost ones) are downloadable from Mojang and running them will host a server on your machine that you can join via localhost or LAN; I usually find the direct links from the Wiki and it has tutorials as well. Getting other people to play on the server requires port forwarding on your router, as hosting other things does unless you're using a third party host or some kind of proxy that handles that for you. If you want to play with friends in the same network on a dedicated server instead of a world opened to LAN, that's free if your machine can handle it. Free hosts like Aternos take care of hosting but have limited freedom. Most other hosts are paid but the reputable paid ones are high-quality.
There's lots of guides and tutorials for self-hosting or you can find hosts online (don't ask me, I only know bits, this could all be a little inaccurate). I do not recommend trying to make a public server unless you know what you're doing, especially since unless you have a domain (which is paid) it will be your personal IP that's exposed. If it's between people you trust well, it's likely fine to use a bare IP.
Stepping on my soapbox for a second: do not listen to the siren song of Essential for playing multiplayer remotely. it's sketchy, bloated, closed-source (so you have to trust them when they say what it does), has microtransactions, and is downloaded as an installer instead of a regular mod file. Use anything else.