An octopus is an intelligent creature, stuck with a "reproduce once, lay thousands of eggs, and then die" life cycle. To benefit from a longer life and evolve to have one, a lot would have to change. Of course what you'd choose to include in a story is up to you.
Let's start simple. For a male octopus to live longer, he may just need a mutation that deactivates (or fails to activate) the "death genes" after mating. Then he may be able to live as long as he can avoid being lunch or any kind of injury. So if you just want one octopus swimming around, contemplating the cruelty and wonder of life for years, you're done. But for the mutation to spread, of course it would need to give his offspring some advantage.
A female octopus lives for a time after laying her eggs, to protect them and fan water over them so they have enough oxygen. She does this to the exclusion of feeding herself (perhaps she has death genes, as well, so feeding is irrelevant). To live longer, as it is now, she'd have to abandon her eggs (or at least care for them less). Of course that's not an advantage, and may stop her genes from getting into the next generation entirely.
If they became cyclic maters, and cared for the eggs together, that would bring more of their genes into future generations. But there's a reason they don't live that way now. Too many would strain the food supply. And an octopus lives a solitary life, avoiding predictors through cunning and stealth—too many in an environment would make predictors more familiar with their tricks.
So unless they somehow happened to find an environment that had no predators and lots of food, they'd need to deal with both food and safety in very different ways. Perhaps it's my species bias, but I tend to think of ways to do this that would mimic human advancements.
Manipulate the coral to grow into protective structures. Promote growth of other species, like farming. Form a symbiotic relationship with another species, like we did with wolves, to help protect the underwater structure and farm from predictors. I don't know what an octopus could bring to such a relationship, but they are much better at escaping than fighting, so they'd need muscle. Obviously they'd need to be social to do all this, and learn to communicate.
Octopus can manipulate the environment. They are strong, and smart. But I doubt they could evolve this way. For one thing, they don't have stamina, and building and maintaining such a system would take a lot of work. They have copper-based blood (like a Vulcan); it evolved to deal with the pressure at depth. Compared to our blood, it is less efficient at carrying oxygen, and it is thicker and harder to push around their circulatory system. So they tend to expend energy in short bursts, and then they are exhausted.
So I'm not really sure what natural conditions would allow them to benefit from a long life. Perhaps if a new sea opened up, an octopus with multiple mating cycles would help fill up their niche faster, but the situation would eventually stabilize and be similar to existing seas.
I keep thinking it would have to involve another species, to evolve naturally. Perhaps if they developed a very close symbiotic relationship, they hitch a ride and get protection in exchange for pulling off lampreys and companionship...? Intelligent creatures on land seem to have some recognition of other intelligent creatures, and sometimes reach out to them. But intelligent land animals are already social, so an octopus may not think this way.
I hope that gives you some ideas to work with.