Why did the Portuguese royal court transfer to Brazil in 1807?

In late November 1807, the Portuguese royal court, along with more than 9,500 people, packed up and fled from Lisbon, Portugal to the colony of Brazil. Led by Queen Maria...