You can keep them and it's not really that difficult, but most reefers are unwilling or unable to make the sacrifices necessary to humanely care for an octopus.
One of the biggest problems that nobody seems to know about is that you have almost no guarantee of what octopus you're going to get when you order from any given vendor. It's totally conceivable that the little 9" octopus you get sold grows into a 2' - 2.5' monster. So if you can't get a guaranteed species, you really should plan to have them alone in a 75 gallon tank or larger.
Some sites will guarantee you a certain species and some of these are rather small. Some dwarfs like O. joubini (available sometimes on Live Aquaria) or O. mercatoris only grow to about a 1" - 2" mantle and COULD fit in a 20 gallon tank. You really ideally should have a bigger tank though, as well as a protein skimmer.
If they ink, which my O. hummelincki seems to do without reason several times a week, you will need to do a water change in fairly short order, as the ink can clog their gills and sometimes contains biological copper. The skimmer will help get some of the ink, but not all of it.
Octopuses generally don't like strong lights and generally won't do well in a reef tank with photosynthetic corals, and they have a habit of eating any tankmates, fish or inverts.
If you get a cooler-water species, you will need a chiller and will need to maintain below reef temperatures to get it to live more than a year or so.
If you can provide clean water and an adequate habitat, there's still the problem of short life expectancy. Dwarf species like O. joubini live a year, tops. Some make it a year and a half, but you have to remember that by the time you get them, they're likely a few months old already. O. mercatoris is a little bigger than O. joubini and will usually live a bit longer, but they're much harder to find.
I certainly won't say don't do it. Keeping an octopus happy and healthy is a really rewarding experience, and they're amazing creatures. I will say, though, if you're not willing to give it enough space or aren't experienced at keeping water parameters stable, I would wait. Those two are really non-negotiable if you want to give it a happy and healthy life.