As befits a dinosaur named after its massive skull-which measured a whopping 10 inches thick on the front and forward side of its head-most of what we know about Pachycephalosaurus is based on skull specimens. Still, that hasn't kept paleontologists from making educated guesses about the rest of this dinosaur's anatomy: it's believed that Pachycephalosaurus possessed a squat, thick trunk, five-fingered hands, and an upright, two-legged posture. This dinosaur has given its name to an entire breed of odd-looking boneheads, the pachycephalosaurs, other famous examples of which include Dracorex hogwartsia (named in honor of the Harry Potter series) and Stygimoloch (aka the "horned demon from the river of hell").
Why did Pachycephalosaurus, and other dinosaurs like it, have such thick skulls? As with most such anatomical quirks in the animal kingdom, the the most likely explanation is that the males of this genus (and possibly the females as well) evolved big skulls in order to head-butt each other for dominance within the herd and win the right to mate; they may also have gently, or not so gently, butted their heads against each others' flanks, or even the flanks of menacing tyrannosaurs and raptors. The main argument against the head-butting theory: two half-ton Pachycephalosaurus males charging each other at top speed might have knocked themselves out cold, which would certainly not be an adaptive behavior from an evolutionary perspective! (Whatever its ultimate purpose, Pachycephalosaurus' block-shaped bean clearly didn't protect it from oblivion; this was one of the last dinosaurs on earth, in the late Cretaceous period, when a meteor impact 65 million years ago rendered the entire breed extinct.)
As with another family of ornamented dinosaurs, the horned, frilled ceratopsians, there's a fair amount of confusion about pachycephalosaurs in general (and Pachycephalosaurus in particular) at the genus and species level. It may well be the case that many "diagnosed" genera of pachycephalosaurs actually represent the growth stages of already-named species; for example, both the above-mentioned Dracorex and Stygimoloch may well turn out to belong under the Pachycephalosaurus umbrella (which will no doubt be a major disappointment to Harry Potter fans!). Until we know more about how the skull of Pachycephalosaurus developed from hatchling to adult, this state of uncertainty is likely to persist.
You might be amused to learn that, in addition to Pachycephalosaurus, there was also a dinosaur named Micropachycephalosaurus, which lived a few million years earlier (in Asia rather than North America) and was a couple of orders of magnitude smaller, only about two feet long and five or 10 pounds. Ironically, the "tiny thick-headed lizard" may have engaged in true head-butting behavior, since its tiny size would allow it to survive head-on impacts unscathed.