The rabbis wonder whether or not a girl can be sold to her relative, particularly if she is permitted to be sold to a master of flawed heritage. The aim is to allow maidservant to fulfill the mitzva of marriage. However, marrying a forbidden relative leads to more serious consequences than other transgressions, including marrying into another family of flawed lineage.
The rabbis teach us that when we purchase a slave, it is as if we have acquired a master. How could that be? A Hebrew slave must be kept in the same conditions as the master himself. He must eat the same food as the master together with the master, for example. The effort that would go into maintaining the standard of living of a Hebrew slave would be difficult to maintain. Thus the slave requires the master's work.
The Gemara then explores the redemption of a Hebrew slave by an idolator, and the partial redemption of a house within a walled city. Both of these issues seem to be beside the point, though the rabbis spend much time on them.
It is fascinating to witness which ideas are considered to be worthy of deep exploration by the rabbis. To my mind, there are a number of questions far more interesting than the ones that the rabbis choose to explore. For example, how do the rabbis understand the valuation of a maidservant as it changes with her age? Or why are girls put in situations that might put them into danger? Or why are girls' opinions about their fathers' selling them do not hold weight when we are dealing with major transgressions? I could go on.