Shakespeare wrote the play in part to please the new King of England, James I, who had previously been James VI of Scotland. Patriotic statements such as this one by Macduff can be seen in that historical context. One difficulty Shakespeare had with this play about a Scottish king was how to present regicide so as not to offend James I. He succeeded in doing this by making Banquo a sort of hero, and James' ancestors could be traced back to Banquo. "Oh Scotland, Scotland" would have been words particularly pleasing to the ear of James I.
In addition, "Scotland" refers to both country and king. We see this convention throughout Shakespeare's works, for example, the King of Denmark is "Denmark," and the convention is still in use in England to this day. Consequently, the line is used as a lament for both slain King and forsaken country. In Act 4, scene 3, where we find "O Scotland, Scotland!," "Scotland" is first used to identified slain King Duncan, then, later, used to identify the country of Scotland.
"Scotland" identifying King Duncan:
Macduff: ...new sorrows
Strike heaven on the face, that it resounds
As if it felt with Scotland and yell'd out
Like syllable of dolour.
"Scotland" identifying the country of Scotland:
Macduff: Bleed, bleed, poor country!
...yet do not fear;
Scotland hath foisons to fill up your will.
This occurs in Act IV, scene iii, when Macduff and Malcolm are speaking about the sad state of affairs in their beloved country of Scotland. Malcolm, the son of the slain king Duncan and rightful heir to the throne, is testing the loyalty of Macduff, making sure that Macduff is really there to support him and his effort at raising an army to take the throne away from Macbeth. This quote, "O Scotland, Scotland!" is a sincere, heartfelt plea of sadness at the state of his beloved country on the part of Macduff.
Check the links below for more information. Good luck!