Shemot20:2

אָנֹכִי יְהוָה אֱלֹהֶיךָ אֲשֶׁר הוֹצֵאתִיךָ מֵאֶרֶץ מִצְרַיִם מִבֵּית עֲבָדִים׃

"I am the Eternal your Almighty, who brought you out of the land of Egypt, out of the house of slavery.

Shemot 20:2

אָנֹכִי יְהוָה אֱלֹהֶיךָ

Shemot / Exodus 20:2 · Sod

Shemot 20:2

אָנֹכִי יְהוָה אֱלֹהֶיךָ אֲשֶׁר הוֹצֵאתִיךָ מֵאֶרֶץ מִצְרַיִם מִבֵּית עֲבָדִים׃

"I am the Eternal your Almighty, who brought you out of the land of Egypt, out of the house of slavery.

Sod סוֹד

A son, not a slave

Why was the Torah given after the going out of Egypt and not before? A condition could have been set: accept the Torah and you will go out. Kedushat Levi explains what would have been wrong with that.

Kedushat Levi: one who serves out of fear is like a slave, and one who serves out of love is like a son. Had the Torah been given before the going out of Egypt, Israel would have accepted it out of fear that otherwise they would not go out, and would have stayed slaves. So the Eternal first brought them out, and then gave the Torah, and they accepted it out of love, as sons. This is "brought you out of the house of slavery": so that you would not be a slave but a son.

How Kedushat Levi explain it

Kedushat Levi I am the Eternal your Almighty, who brought you out of the land of Egypt, out of the house of slavery

See Rashi on the words "out of the house of slavery". And it seems that this is why the Holy One, blessed is He, gave the Torah to Israel after the going out of Egypt, and did not give them the Torah before and then bring them out of Egypt. The rule is: one who serves out of fear is called a slave, and one who serves out of love is called a son. So had He given them the Torah before the going out of Egypt, Israel would have accepted the Torah out of fear: if, Heaven forbid, they did not accept the Torah, the Holy One, blessed is He, would not bring them out of Egypt. And they would have been as slaves. So the Holy One, blessed is He, first brought them out of Egypt, and afterwards they accepted the Torah. Surely Israel accepted the Torah out of love, and they are as sons. This is "who brought you out of the land of Egypt", and now I give you the Torah. And "brought you out of the house of slavery": so that you would not be as a slave, but as a son.

Takeaway

Rashi on the words "out of the house of slavery" explains: out of the house of Pharaoh, to whom you were slaves. Kedushat Levi starts from this and goes further: the Torah brings out not only from slavery to Pharaoh but also from service out of fear.
"Slave" and "son" for the Chassidim are two levels of service: a slave serves so that there is no punishment, a son serves because he loves his Father.