It's simple, they could either fight a brutal bloody war to the death with the Romulans or they could agree not to develop cloaking tech (but still develop anti-cloaking countermeasures).

And we don't know what the Romulans gave up in return. They never use that super-powerful plasma torpedo the BOP in Balance of Terror again, maybe they agreed not to further develop THAT tech in exchange.