To me, the phrase "Be careful what you wish for (you just might get it)" advises somebody to take care before making a particular choice, as it may have unforseen repercussions. A person may be about to take an action that may at first glance appear to lead to a desirable outcome (the outcome they wish, or hope for) but there may be negative effects to taking this action, which the person failed to notice during their preoccupation with achieving those initial positive aspects.
Another possible interpretation, less cautionary and more just a pessimistic outlook on life, is similar to "The grass isn't always greener" (or is always greener, if you're using the insincere form of the phrase, nevertheless implying that it actually isn't greener).
Basically, "however s**t you think things are, don't bother wishing for something better because chances are, that'll be just as s**t. Or probably even worse."
Or to boil it down even further, "Everything is a big pile o' crap, we're just wading through different areas of it."