In Shemot 20:10 it is said the Shabat is important because HaShem creation caused 6 days and HaShem rested on the seventh. That one seems logical, because of this we also work 6 days and then keep the Shabat.
But in Devarim 5:14 it says that the Shabat is important because HaShem set us free from slavery.
But what is the connection between the Shabat and being took out or freed from the slavery of Mitzrayim? How is being set free be the reason for keeping the Shabat?