Emoticons and emoji are used to bring nuance to short text passages that might be misunderstood otherwise. Of course, some folks use it for decoration, emphasis, and humor, but that wasn't the original idea. Written language was first used to convey information, but as time passed and technology enabled communication over distances, humanity has struggled to imbue text communication with implied emotion that can get lost when you can't see the speaker's facial expressions and body language. At their core, such symbols are a form of punctuation, which was an early innovation in writing -even before spaces between words. Emoticons and emoji were not so much invented but instead evolved from the long process of refining written text. To understand this evolution, it helps to have a timeline of punctuation. The digital revolution ramped up the need for shortcuts in passing along in idea in text.
This all inspired the users of, for example, the PLATO IV system in 1972 to actually use a facility of that system to solve the problem, creating a whole slew of the first emojis and emoticons in the process.
And if you’re wondering about the distinction here, “emoji” derives from the Japanese for “picture” and “character”, so “picture character”. In contrast, “emoticon” derives from the English “emotion icon”. Thus, while you might think given the two words’ similarity and what they represent also being similar that one came from the other, this is actually purely coincidental.
In any event, going back to the PLATO IV system, with this system, users could press SHIFT-space and then a character to have that character plotted over the previous character without overwriting it. Particularly clever users used this fact to come up with all sorts of little images to represent various emotions and otherwise add context and meaning to a given bit of text, or sometimes to just have the thing stand alone to communicate something, like some sort of modern hieroglyphic. Eventually there were many hundreds of such symbols being used on this system.
There are other important moments in the development of emoticons, such as the time a theoretical discussion about a pigeon, a candle, and some mercury inside a falling elevator leaked outside of the chat forum at Carnegie Mellon University and almost caused a panic. Discussion of the incident emphasized the need for a way to denote something as a joke, which led to the sideways smiley face being widely adopted. Read a fairly in-depth history of punctuation that gave rise to emoticons and emoji at Today I Found Out.