I know this may be a stupid question but every time I look at a map their is a dashed line between Morocco. Why is this? Is the territory disputed or what?
Do you mean a horizontal line running along the latitude of 27 deg 40" N, slightly south of Canary Islands? If yes, the your assumption is correct. This is a border between Morocco and Western Sahara, with the latter state being a disputed territory as it is acknowledged as an independent political entity by 50 countries, while being treated as an integral part of the country (the 'Southern Provinces) by Moroccan authorities.
The divide is to a large extent a result of the 19th-century colonial politics, as the territory of what is now Morocco has been divided between France and Spain, with the former treating Morocco as its protectorate, and the latter laying claim to what is now Western Sahara, the city of Ifni and relatively narrow strips of land, one on the Mediterranean shore, between Tangiers and Melilla and the other between what is now the northern border of Western Sahara and Draa river.
In 1966, an independentist Liberation Movement has been founded and in 1970 the first major military action against the Spanish forces has been taken, yet this attempt, known as Zemla Intifade, ended with defeat of the Western Saharans. This led to the formation of another independence organization commonly known in Western historiography as Polisario (sp. Frente POpular para la LIberación de SAguia el Hamra y RIO de Oro) that was formed in 1973 in Algeria. Resulting tensions caused dying Francisco Franco to withdraw Spanish military from the area and call for national referendum in 1975.
Morocco, having been an independent country since 1958, was also laying claim to the Western Sahara and thus attempted to capitalize on the withdrawal of Spain from this part of Africa. The mass demonstration where more than 300.000 civilians crossed the former colonial border was followed by the incursion of the Moroccan army that captured key cities. Facing a war with Morocco, Spanish authorities decided to withdraw completely from their former colony. Newly acquired territory has been then divided between Morocco and Mauretania. Polisario Front, supported by Algeria and Libya, forcibly opposed the new occupants, proclaiming an independent state of Saharian Arabic Democratic Republic. Mauretania eventually withdrew from conflict in 1979, what was followed by acknowledgement of the independence of Western Sahara in 1984. Nevertheless, the war with Moroccan forces continued throughout the 1980s, with the latter gaining and maintaining control over the subsequently larger areas of the western part of the country and building a series of sand walls manned by the Moroccan military, effectively creating the controlled border between the Western, more economically viable areas and the eastern territories held by Polisario Front.
The war formally ended with an armistice in 1991, although the state of the area is still disputed. In 1997, during the talks between Moroccan authorities and Polisario Front, UN representative James Baker proposed the autonomy of Western Sahara, with the issues related to the defense and foreign affairs being handled by Morocco. This was rejected by Polisario that stated they can't accept any solution that does not include total independence of the region, what led to a second proposal, where Western Sahara was to receive a 5-year autonomy autonomy, after which time the potential independence to be determined by a popular referendum. The talks ended with the signing of Houston Agreement, where both parties agreed to create a plan leading to the enforcement of the resolution. So far, the political tensions, lack of consensus regarding the identity of Western Saharan citizens available to participate in potential referendum and Baker's retirement caused the solution of the conflict to stay in the political limbo.
So, to sum it up, the dashed line dividing Morocco in half is de facto border between Morocco proper and Western Sahara that is a disputed territory, although more than half of its territory is controlled by Moroccan government.