The writer of Ecclesiastes is, also, named Ecclesiastes. (It's a self-titled debut—like The Clash.) As was mentioned earlier, the Hebrew version of this is Koheleth, which means the "Gatherer," the "Assembler," the "Preacher," or the "Teacher." Take your pick. He claims to be King David's son, but this is likely a way of getting cred as a member of the royal family, so people will take the words of the book's author (or authors) seriously. It naturally made people think of King Solomon, since he was supposed to be unusually wise, but it could also be a sort of experiment—Ecclesiastes is playing the character of a king to show that even the wisdom and possessions that a king has don't, in the end, create happiness or remove confusion from life.
We know that Ecclesiastes partied hard as a young man—and maybe as a middle-aged man, as well. Not only did he want to learn about wisdom, but about folly and "madness" too. He writes,
I searched with my mind how to cheer my body with wine—my mind still guiding me with wisdom—and how to lay hold on folly, until I might see what was good for mortals to do under heaven during the few days of their life. (NRSV 2:1-3)
In Hebrew, the term for "madness" means something more like totally giving into pleasure, without thinking. It's basically the exact opposite of what the Hebrews meant by wisdom: guzzling wine, chasing after probably meaningless sex, and not using a single brain cell for anything worthwhile. So, Ecclesiastes admits he did all this. He's seen it all, man… but it turned out to be vanity. He also tried to build up his kingdom, create and amass treasures, buy slaves and gardens and concubines—but that was vanity, too.
In the past, Ecclesiastes says he's been depressed because everything turned out to be vanity—until he realized that being depressed about this is, itself, vanity:
How can the wise die just like fools? So I hated life, because what is done under the sun was grievous to me; for all is vanity and a chasing after wind. (NRSV 2:12-17)
So, at the end of the day, you need to content yourself with the basic enjoyments and to take pleasure in your work, rather than in the rewards or results of your work, since those might get stolen or destroyed. Ecclesiastes is kind of like an old ex-Hell's Angel biker—he's been around the block more than a few times, and he's probably done some pretty bad things. But now that he's settled down, all the experiences he's had—including his experiences with "folly and madness"—have helped to build up his wisdom. Even his observation that more wisdom leads to more sorrow, is itself an example of wisdom.
Speaking of bikers and the Hell's Angels, the writer Harold Bloom says there's something about Ecclesiastes that reminds him of a "Fallen Angel." Ecclesiastes (in Bloom's view) is someone who seems to understand the world around him really well, but ultimately finds it utterly empty and pointless. He has the intelligence of an angel or a god, but that intelligence isn't really used for a higher purpose. It just keeps criticizing the world—chipping away at it one bit at a time—until it seems totally worthless and absurd.
He's a little like Shakespeare's Hamlet, that way—he can't help picking at his own scabs, so to speak. Hamlet can't just relax, kick back on a nice Danish beach, and order a virgin banana daiquiri (or whatever it is they drink on Danish beaches). But that's exactly the kind of thing Ecclesiastes keeps telling us to do. We should "eat, drink, and be merry."
But is Ecclesiastes merry? Or, can you be merry if you see that absolutely everything is totally vain and illusory? He seems to think that you can—or, at least, he says that he thinks so. Whether he proves it or not, is of course, a call for the reader to make.
There are more cheery perspectives on Ecclesiastes's personality. The Canadian writer Northrop Frye was another famous literary critic (well, as "famous" as literary critics can be, anyway), and he sees Ecclesiastes as someone who's trying to free us from any and all illusions in order to live a fuller life. It's one of the Bible's biggest paradoxes—when you see that there's nothing that lasts, that everything is "vanity," you realize that there's no point in being attached to anything anymore. You actually become free to pursue genuine happiness, because you're no longer a slave to delusions. You're not going to get hung up on money or on getting 15 minutes of fame, or starring on The Surreal Life.
Yet, since Ecclesiastes says it doesn't make sense to get stuck on any particular thing, you're suddenly totally free to live your life with pure energy. All the energy you have isn't getting wasted on frivolous pursuits—you know that your life is limited, and you know that you won't be able to enjoy wealth if you just pile it up. So you concentrate, instead, on the things Ecclesiastes is always shouting about: enjoying the good and simple things: eating, drinking, and finding creative work to do. And you should do that work with "all your might."
So, at the end of the day, however you try to slice him up, Ecclesiastes isn't just an elderly party boy. He's not telling anyone to "live fast, die young, and leave a beautiful corpse." He is telling people to appreciate what's really good in life while there's still time, and to take joy in finding some kind of productive labor to do. Otherwise, you just have illusions to cling to—a king-size bundle of (say it with us) vanity.