The phrase originates from the word “Pun” which simply put means: a play on words, where you try to describe something with a term or phrase which has multiple meanings but the two don’t necessarily correspond, hence creating a pun.
When using the phrase “No pun intended” you basically bypass the possibility of giving something two meanings (where one is intended and the other one must be taken out of context) and point out the obvious one.
It is not possible to determine the exact origin of phrase as it is very likely to predate the use of the internet and there is no information to be found recorded of it.
The term first surfaced on the Urban Dictionary in 2009, where a user has submitted a very poor explanation and meaning, which has later gained lots of attention and spawned many other entries, correcting the initial false information.
After surfacing in 2009 messaging boards and forums have jumped on the hype train without hesitation, making the phrase a “daily driver”.
You can find the phrase on conversation screenshots or pictures of situations that can be easily be taken out of context, mostly posted on the websites 4chan, Reddit and 9gag.