I found a flight that has a connection in Japan that's cheaper than a direct flight to Japan. Is it legal to take that cheaper flight and leave the airport at the layover location as our final destination? Will they prevent us from taking the return flight?
Are you breaking criminal law? No. So it's not criminally illegal
Are you breaking a civil law contract? Probably not.
Is the company who sold you the original ticket obligated to do more business with you going forward after you skip a leg? No they're not obligated to continue doing business with you
Is it morally unethical? No. The plane is flying regardless.
Basically it's up to you, how much administrative hassle you're willing to put up with
In your scenario, you bought a round trip ticket, the airline is unlikely to honor the return on that round trip ticket from the middle airport. They probably have requirements like you have to be at the beginning leg of a flight to have the ongoing legs. In all likelihood they'll cancel the return side of your ticket if you miss an outgoing leg. Why would you need the return, if you never made it to your destination?
If you're going to do skip legged travel, it should be one way flights. You still could get back listed by the airline but it's unlikely. You could just say you had a medical emergency, family emergency, you overslept, got drunk at the airport, life happens. And they can't prove it one way or the other especially if it's a one-way flight