It creates dramatic tension and sets the play into action. Call it a 'rhyming couplet' rather than just 'rhyme'. It also provides a sense of cadence at the end of the scene/act.
Yes, it sustains the foreboding atmosphere of the early scenes within the play. I would also add that it provides an insight into Hamlet's disillusionment and impending psychosis from society.