I tried to summarize briefly Scotland's history. Can you please have a look at it? Which form is correct: in 9th century/in the ninth century?

6th century (AD): 500-599 (is it correct?)
9th century (AD): 800-899
10th century: 900-999

1) The first inhabitants of Scotland were the Picts and the Scots. The former were of Celtic origin whereas the latter came from Ireland.
2) In 120 AD the Roman Emperor Hadrian had a wall built to keep the Scottish out. In the sixth century Christianity was introduced into Scotland by Irish missionaries.
3) In 9th century Scotland was united under the same King for the first time to fight off the Vikings. These were finally defeated in the 10th century.
10th they managed to repulse the Vikings.
4) In 1018 the Scottish King Malcolm II defeated the Northumbrians. His grandson became his successor as Duncan I. In 1040 Duncan was killed by his general, Macbeth. Macbeth ruled until 1057, when he was defeated by Duncan’s son Malcolm III Canmore.
5) Macbeth spent many years in exile and eventually married an English princess. In the 13th century the English King Edward I invaded Scotland and seemed to have defeated the country.
6) 1314 the Scots rebelled and defeated the English Army. After this battle Scotland and England remained two separate countries for nearly 300 years.

"in the ninth century" = correct

(But then you'd say, "In 9th century Rome...")

6th century (AD): 501-600
9th century (AD): 801-900
10th century: 901-1000
Remember: The first century didn't start with year 0!! It started with year 1. So the 1st century included the years 1-100, and all the others fall into that pattern.

1. comma needed

2. commas needed

3. comma needed, no capital on "King" unless you're naming a specific king.

4. commas needed; one comma not needed

5. comma needed; I'd say "defeated the Scots" or "conquered the country."

6. missing word at the beginning; commas needed

Overall, your summary of Scotland's history is quite accurate. However, there are a couple of minor corrections and clarifications to be made.

1) The first inhabitants of Scotland were indeed the Picts and the Scots. The Picts were a Celtic people, while the Scots originated from Ireland.

2) In 120 AD, the Roman Emperor Hadrian had a wall built to keep the Picts and other northern tribes out. However, it is worth mentioning that this wall, known as Hadrian's Wall, was not specifically aimed at keeping the Scottish people out, but rather to mark the northernmost frontier of the Roman Empire.

3) In the 9th century, Scotland was indeed united under the same king for the first time to resist Viking invasions. The Vikings were eventually defeated in the 10th century.

4) In 1018, the Scottish King Malcolm II achieved a significant victory over the Northumbrians. His grandson, Duncan I, succeeded him as king. However, Duncan was killed by Macbeth, not Macbeth's general. Macbeth then ruled until 1057 when he was defeated by Malcolm III Canmore, Duncan's son.

5) Macbeth did spend some years in exile, but it is not recorded that he married an English princess. It is also worth mentioning that the English King Edward I invaded Scotland in the 13th century, not specifically in the 12th century. Edward I's invasion indeed posed a threat to Scottish independence.

6) In 1314, the Scots, led by Robert the Bruce, rebelled against English rule and achieved a significant victory over the English army at the Battle of Bannockburn. Following this battle, Scotland and England remained separate countries for several centuries, until the Union of the Crowns in 1603.

As for your question about the correct form, both "in the 9th century" and "in the ninth century" are grammatically correct. However, "in the 9th century" is more commonly used in historical contexts. Similarly, "5th century (AD): 500-599" is correct, but it is more typical to write "5th century (AD): 400-499" to indicate that it represents the years from 400 to 499 AD. The same applies to "6th century (AD): 500-599".