A friend of mine is transiting through Heathrow Terminal 5 and they don't have a UK visa. In order to meet my friend, I am planning to book a cheap flight out of Terminal 5 around the same time my friend will be in the transit so I can clear to security and spend a few hours with my friend then I will leave the airport without flying. Any issues with that plan?
Couple things to add to all of the above answers. First, as pointed out in another answer, it's best to book a flight with the departure time around the same time as you friend's departure time (so as to not stick around too long after your flight departure).
And second, as a matter of courtesy, before the departure of your booked flight, do come to the airline's desk airside and inform them that something personal has come up and you are not going to fly. No need to go into the details - just make sure the airline knows that you won't be flying. This will avoid them calling "Passenger such-and-such, this is your last call, please come to the boarding gate immediately", and may free up a seat for somebody that really needs to fly. Moreover, you may be able to get some money our of it, even with the cheapest ticket, as the taxes portion may be refundable.
At Heathrow T5 through the use of biometrics, domestic and international (+international transit) passengers are able to mix. For this reason it isn't possible to just walk out once you 'miss' your booked flight.
You need to go to customer services airside and request to be added to a list to be walked out through immigration - they do this around once an hour and someone will come from security to escort the group out of the mixed departures lounge, through UK immigration. I've done this a couple times before when for example flights are cancelled or I've missed connections.
While I don't see any issue with your plan, bear in mind that it can take time to wait for a group to be escorted out, and you will have interaction with both BA and the immigration staff on why you need to leave the terminal and didn't take your flight etc.
While ID wouldn't be required for a domestic flight, I'd recommend taking some with you just in case the biometric system failed and you were asked to prove your identity and right to remain in the UK when passing immigration on leaving the terminal.
People buy refundable plane tickets, get to the gate, and then don't take the flight. Generally this has no consequences for them. If someone comes to believe that you are not just a business traveler whose meeting was cancelled just as the flight was boarding, then you might find that the airline chooses not to sell you a ticket some other time in the future.
People have done this before, usually for lounge access. This blog has some tips. This Quora question ranges from "if you go in the lounge you won't get a refund" to "sure it's cool". This article says United is cracking down on people who do this, but again that's about using the lounge. This article says "many world carriers do have rules in their ticketing contracts forbidding the practice of purchasing tickets that you have no intention to fly" where of course the issue is demonstrating "you have no intention" of flying, and then after that, what the airline is going to do about it.
In practice, I think airline consequences happen to people who are using airport lounges for 12 hour free food-and-drink sessions day after day, not to someone who does this once. Nevertheless, I would strongly encourage you to do this at most once. It is a trick. You are consuming effort by airline people, and possibly keeping someone else from buying a ticket they truly want, in order to get around the visa rules of your country.
Also, don't stick around after the departure time of that flight you're not taking. I think that makes it more obvious that you didn't cancel the flight just because your meeting was cancelled or you had an emergency at home, but rather that you never intended to take it.
Any issues with that plan?
You buy a ticket so the airline gets their money and has really nothing to complain about. While it may technically violate the spirit of the terms and conditions, it's inconsequential: people miss their flights all the time for all sort of different reasons. It's perfectly normal and the airline will not pay any attention to it.