In universe, she was the head of Starfleet Medical.
From "The Child":
WESLEY: It's going to be hard leaving the Enterprise.
PICARD: Mixed feelings for all of us. It's always difficult leaving any ship, just as it was for your mother when she left to become head of Starfleet Medical.
When she returned, not a lot was said, but in "Evolution" it's implied that she may have returned because it was difficult to be separated from Wesley:
PICARD: If you're concerned about Wesley, I see no evidence that there's a problem.
BEVERLY: I know. In a funny kind of way...that's exactly my point. We talk. We smile. It's almost too polite.
PICARD: Beverly, this is simply a matter of time. I know how difficult it was to be away.
BEVERLY (vulnerable): Tell me about him.
Out-of-universe, then-head writer Maurice Hurley didn't like her.
According to some recent reports, there was some sort of problem between Gates McFadden and producer/writer Maurice Hurley. I've heard this characterized in some places as sexual harassment, but I'm not sure that's based on any actual allegations. Rick Berman did say he was at the center of it, though:
Gates McFadden fired at end of first season because head writer Maurice Hurley "he had a real bone to pick" with Gates and din’t [sic] like her acting, Berman brought Gates back for 3rd season after Hurley left
(That quote is from the summary here.)
This comment also cites her hair (of all things) as costing lots of time and money to keep styled right to avoid continuity problems. Not sure I buy it, but there it is.