Consider an arbitrary equilateral triangle $KLM$, whose vertices $K, L$ and $M$ lie on the sides $AB, BC$ and $CD$, respectively, of a given square $ABCD$. Find the locus of the midpoints of the sides $KL$ of all such triangles $KLM$.
1. **Define the problem and setup:**
   Consider an equilateral triangle \( KLM \) inscribed in a square \( ABCD \) such that the vertices \( K, L, \) and \( M \) lie on the sides \( AB, BC, \) and \( CD \) respectively. We need to find the locus of the midpoints of the sides \( KL \) of all such triangles \( KLM \).

2. **Identify the midpoint \( E \) of \( KM \):**
   Let \( E \) be the midpoint of \( KM \). Since \( KLM \) is an equilateral triangle, \( E \) is also the centroid of \( \triangle KLM \).

3. **Cyclic quadrilaterals:**
   Notice that quadrilaterals \( BLEK \) and \( CMEL \) are cyclic. This is because the angles subtended by the same arc in a circle are equal. Specifically, we have:
   \[
   \angle LBE = \angle LKE = 60^\circ
   \]
   Similarly,
   \[
   \angle LCE = 60^\circ
   \]

4. **Equilateral triangle \( \triangle BCE \):**
   Since \( \angle LBE = \angle LCE = 60^\circ \), it follows that \( \triangle BCE \) is equilateral. This implies that \( E \) is a fixed point because the equilateral triangle \( \triangle BCE \) is uniquely determined by the side \( BC \) of the square.

5. **Midpoint of \( KL \):**
   The midpoint of \( KL \) is the circumcenter of the cyclic quadrilateral \( BLEK \). The circumcenter of a cyclic quadrilateral lies on the perpendicular bisector of any of its sides. In this case, it lies on the perpendicular bisector of \( BE \).

6. **Conclusion:**
   Since \( E \) is a fixed point and the midpoint of \( KL \) lies on the perpendicular bisector of \( BE \), the locus of the midpoints of \( KL \) is a line segment parallel to \( AD \) and passing through the midpoint of \( BE \).

The final answer is the line segment parallel to \( \boxed{ AD } \) and passing through the midpoint of \( BE \).